Class: Hash
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
- #oo_eql ⇒ Object
- #subset(keys = nil, &block) ⇒ Object
- #to_openobject(deep = false) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
152 153 154 155 156 |
# File 'lib/ruby_ext/open_object.rb', line 152 def == other true if self.equal? other other == self if other.is_a? OpenObject oo_eql other end |
#oo_eql ⇒ Object
151 |
# File 'lib/ruby_ext/open_object.rb', line 151 alias_method :oo_eql, :== |
#subset(keys = nil, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby_ext/hash.rb', line 2 def subset keys = nil, &block h = {} if keys self.each do |k, v| h[k] = v if keys.include? k end else self.each do |k, v| h[k] = v if block.call k end end h end |
#to_openobject(deep = false) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/ruby_ext/open_object.rb', line 135 def to_openobject deep = false unless deep OpenObject.new.update self else r = OpenObject.new each do |k, v| r[k] = if v.is_a? Hash v.to_openobject else v end end r end end |