lib/demiurge/util.rb
# This operation duplicates standard data that can be reconstituted from
# JSON, to make a frozen copy.
This operation duplicates standard data that can be reconstituted from
JSON, to make a frozen copy.
This operation duplicates standard data that can be reconstituted from JSON to make a frozen copy .
def copyfreeze(items)
      case items
      when Hash
        result = {}
        items.each do |k, v|
          result[k] = copyfreeze(v)
        end
        result.freeze
      when Array
        items.map { |i| copyfreeze(i) }
      when Numeric
        items
      when NilClass
        items
      when TrueClass
        items
      when FalseClass
        items
      when String
        if items.frozen?
          items
        else
          items.dup.freeze
	end
      else
        STDERR.puts "Unrecognized item type #{items.class.inspect} in copyfreeze!"
        items.dup.freeze
      end
    end
def copyfreeze ( items ) case items when Hash result = { } items . each do | k , v | result [ k ] = copyfreeze ( v ) end result . freeze when Array items . map { | i | copyfreeze ( i ) } when Numeric items when NilClass items when TrueClass items when FalseClass items when String if items . frozen? items else items . dup . freeze end else STDERR . puts "Unrecognized item type #{items.class.inspect} in copyfreeze!" items . dup . freeze end end
This operation duplicates standard data that can be reconstituted from
JSON, to make a frozen copy.
This operation duplicates standard data that can be reconstituted from JSON to make a frozen copy .
items