This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am estum on github. | |
* I am estum (https://keybase.io/estum) on keybase. | |
* I have a public key ASCBUSe8TPNeG3_gFmmy3hMi6Azmxilwu-gM4ftWje5ruAo | |
To claim this, I am signing this object: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class MultikeyMap | |
include Enumerable | |
# Creates multikey map from a dict { value => alias | [aliases...] }, | |
# i.e. both key and values will be mapped to key. | |
# @param dict [Hash] | |
# @raise [TypeError] if input can't be coerced as hash | |
# @return [MultikeyMap] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Before (creates prepared statement for each varying size of given array): | |
# | |
# $ Post.where(id: [uuid1, uuid2]) | |
# => Post Load (0.6ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" IN ($1, $2) [["id", "a830f21d-a27b-4bde-8c05-6e5dd088712e"], ["id","531ee026-d60d-4a59-a9a5-d44c44578a98}"]] | |
# | |
# After (the only one statement for varying size of given array): | |
# | |
# $ Post.where(id: [uuid1, uuid2]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "dry-initializer" | |
# Simply generates insert statement with optional overridings. | |
# === Usage: | |
# | |
# like = Like.last | |
# # => #<Like:0x00007f8a42b07858> { | |
# # :id => "f93c47dc-9e09-4bf4-bbcb-2ec2000a873f", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# A tiny singleton to generate JSON templates. | |
# | |
# === Example: | |
# | |
# template = JSONWildcard["example" => Array.new(5, "%s")] | |
# # => {"example":[%1$s,%2$s,%3$s,%4$s,%5$s]} | |
# | |
# JSONWildcard.format(template, 1, 2, 3, 4, 5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# = Yieldable | |
# | |
# This is meta-mixin, which makes your module, class or it's instance to respond | |
# to method +to_proc+, for example, to easily build instances during iteration: | |
# | |
# ["1", "2", "3"].map(&SomeObject) | |
# | |
# It is 2 different ways to use this module: +extend+ or +prepend+ it to your class. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
module Dry | |
module Initializer | |
# @example | |
# class CreateOrder | |
# extend Dry::Initializer | |
# | |
# # Params and options | |
# param :customer, model: 'Customer' # use either a name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'concurrent/map' | |
# {include:file:concurrent/map.rb} | |
class Map < Concurrent::Map | |
HashBuilder = proc do |hsh, default = nil, default_proc = nil| | |
hsh = ::Hash[hsh] | |
if !default.nil? | |
hsh.default = default |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require 'concurrent/map' | |
# = Expand Constant Namespace | |
# | |
# To expand namespace in classic way it have to be included or extended | |
# to a target module or class. | |
# | |
# This module provides +expand_constant+ method to expand external module namespace |