Sha256: 5dcb77a0ff2dab73b0a5023494a173e52b7059e008f8af78f9ea9b78a4de6923
Contents?: true
Size: 511 Bytes
Versions: 10
Compression:
Stored size: 511 Bytes
Contents
class HashDsl attr_reader :hash alias :to_hash :hash alias :to_h :hash def initialize @hash = {} end def self.from_block(block) HashDsl.new.tap { |dsl| dsl.instance_eval(&block) } end def self.hash_from_block(block) from_block(block).to_hash end def method_missing(method_name, *args, &block) if block_given? @hash[method_name] = HashDsl.hash_from_block(block) elsif args.length == 1 @hash[method_name] = args.first else super end end end
Version data entries
10 entries across 10 versions & 1 rubygems