Sha256: aaa0b159d2c3c544d07dd5a927b9653095a5b37539f9002f2db231b70bb6748a
Contents?: true
Size: 916 Bytes
Versions: 6
Compression:
Stored size: 916 Bytes
Contents
module Trestle module Lazy module Constantize def constantize(value) case value when String value.safe_constantize when Proc value.call else value end end end class List include Enumerable include Constantize def initialize(*items) @list = items end def each(&block) @list.each do |item| yield constantize(item) end end def <<(items) @list += Array(items) end end class Hash include Enumerable include Constantize delegate :[]=, :key?, to: :@hash def initialize @hash = {} end def each(&block) @hash.each do |key, value| yield key, constantize(value) end end def [](key) constantize(@hash[key]) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems