Class: Hash
- Defined in:
- lib/ruby_ext/core/hash.rb,
lib/ruby_ext/core/open_object.rb
Direct Known Subclasses
Instance Method Summary collapse
- #==(other) ⇒ Object
- #oo_eql ⇒ Object
- #subset(*keys, &block) ⇒ Object
- #to_openobject(deep = false) ⇒ Object (also: #to_oo)
- #validate_options!(*valid_options) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
161 162 163 164 165 |
# File 'lib/ruby_ext/core/open_object.rb', line 161 def == other true if self.equal? other other == self if other.is_a? OpenObject oo_eql other end |
#oo_eql ⇒ Object
160 |
# File 'lib/ruby_ext/core/open_object.rb', line 160 alias_method :oo_eql, :== |
#subset(*keys, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ruby_ext/core/hash.rb', line 2 def subset *keys, &block keys = keys.first if keys.first.is_a? Array 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 Also known as: to_oo
155 156 157 |
# File 'lib/ruby_ext/core/open_object.rb', line 155 def to_openobject deep = false OpenObject.initialize_from self, deep end |
#validate_options!(*valid_options) ⇒ Object
17 18 19 20 |
# File 'lib/ruby_ext/core/hash.rb', line 17 def * = keys - raise "unknown options :#{.join(': ')}!" unless .empty? end |