Class: FinerStruct::Mutable
- Inherits:
-
Object
- Object
- FinerStruct::Mutable
- Defined in:
- lib/finer_struct/mutable.rb
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Mutable
constructor
A new instance of Mutable.
- #method_missing(method, *arguments) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Mutable
Returns a new instance of Mutable.
7 8 9 |
# File 'lib/finer_struct/mutable.rb', line 7 def initialize(attributes) @attributes = attributes.dup end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/finer_struct/mutable.rb', line 11 def method_missing(method, *arguments) if @attributes.has_key?(method) @attributes[method] elsif is_assigment?(method) && @attributes.has_key?(key_for_assignment(method)) @attributes[key_for_assignment(method)] = arguments[0] else super end end |