Sha256: 2f546fda811b25543ccb232ed4da10f0657a0e106c6cf1b9ba05c2421368527f
Contents?: true
Size: 882 Bytes
Versions: 4
Compression:
Stored size: 882 Bytes
Contents
# TO BE DEPRECTATED!!! require 'facets/more/openhash' OpenObject = OpenHash # Core Extensions class NilClass # Nil converts to an empty OpenHash. def to_openobject OpenObject.new end end class Hash # Convert a Hash into an OpenHash. def to_openobject OpenObject[self] end end class Proc # Translates a Proc into an OpenHash. By droping an OpenHash into # the Proc, the resulting assignments incured as the procedure is # evaluated produce the OpenHash. This technique is simlar to that # of MethodProbe. # # p = lambda { |x| # x.word = "Hello" # } # o = p.to_openhash # o.word #=> "Hello" # # NOTE The Proc must have an arity of one --no more and no less. def to_openobject raise ArgumentError, 'bad arity for converting Proc to openhash' if arity != 1 o = OpenObject.new self.call( o ) o end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.49 | work/openobject-temp.rb |
facets-1.8.0 | lib/facets/more/openobject.rb |
facets-1.8.20 | work/openobject-temp.rb |
facets-1.8.8 | work/openobject-temp.rb |