Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ignition/core/hash.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#except(*keys) ⇒ Object
def empty? (count == 0) end.
-
#except!(*keys) ⇒ Object
Replaces the hash without the given keys.
-
#method_missing(key, value = nil) ⇒ Object
def accessed @accessed.uniq end.
- #remove_empty ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, value = nil) ⇒ Object
def accessed
@accessed.uniq
end
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ignition/core/hash.rb', line 14 def method_missing(key,value = nil) # puts "method_missing" # puts key # puts value if self.has_key?(key) self[key] elsif self.has_key?(key.to_s) # if @record_access # puts "here #{key.to_s }" # puts @accessed.nil? # @accessed << key.to_s # end self[key.to_s] elsif key.to_s.include?("=") self[key.to_s.gsub("=","")] = value else super end end |
Class Method Details
Instance Method Details
#except(*keys) ⇒ Object
def empty?
(count == 0)
end
65 66 67 |
# File 'lib/ignition/core/hash.rb', line 65 def except(*keys) dup.except!(*keys) end |
#except!(*keys) ⇒ Object
Replaces the hash without the given keys.
70 71 72 73 |
# File 'lib/ignition/core/hash.rb', line 70 def except!(*keys) keys.each { |key| delete(key) } self end |
#remove_empty ⇒ Object
34 35 36 37 38 |
# File 'lib/ignition/core/hash.rb', line 34 def remove_empty delete_if do |k, v| v.nil? end end |