Module: Mingo::Properties
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #[](field, &block) ⇒ Object
- #[]=(field, value) ⇒ Object
- #initialize ⇒ Object
- #inspect ⇒ Object
- #merge!(other) ⇒ Object
- #replace(other) ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#[](field, &block) ⇒ Object
55 56 57 |
# File 'lib/mingo/properties.rb', line 55 def [](field, &block) @_data.send(:[], field, &block) end |
#[]=(field, value) ⇒ Object
59 60 61 |
# File 'lib/mingo/properties.rb', line 59 def []=(field, value) @_data[field] = value end |
#initialize ⇒ Object
44 45 46 47 |
# File 'lib/mingo/properties.rb', line 44 def initialize(*) super @_data = {} end |
#inspect ⇒ Object
49 50 51 52 53 |
# File 'lib/mingo/properties.rb', line 49 def inspect str = "<##{self.class.to_s}" str << self.class.properties.map { |p| " #{p}=#{self.send(p).inspect}" }.join('') str << '>' end |
#merge!(other) ⇒ Object
67 68 69 70 |
# File 'lib/mingo/properties.rb', line 67 def merge!(other) @_data.merge!(other.to_hash) self end |
#replace(other) ⇒ Object
72 73 74 75 |
# File 'lib/mingo/properties.rb', line 72 def replace(other) @_data.replace(other.to_hash) self end |
#to_hash ⇒ Object
63 64 65 |
# File 'lib/mingo/properties.rb', line 63 def to_hash @_data.dup end |