Module: Committee::Utils
- Defined in:
- lib/committee/utils.rb
Class Method Summary collapse
- .deep_copy(from) ⇒ Object
-
.indifferent_hash ⇒ Object
Creates a Hash with indifferent access.
Class Method Details
.deep_copy(from) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/committee/utils.rb', line 12 def self.deep_copy(from) if from.is_a?(Hash) h = Committee::Utils.indifferent_hash from.each_pair do |k, v| h[k] = deep_copy(v) end return h end if from.is_a?(Array) return from.map{ |v| deep_copy(v) } end return from end |
.indifferent_hash ⇒ Object
Creates a Hash with indifferent access.
(Copied from Sinatra)
8 9 10 |
# File 'lib/committee/utils.rb', line 8 def self.indifferent_hash Hash.new { |hash,key| hash[key.to_s] if Symbol === key } end |