Class: SGF::Model::PropertyHandler
- Inherits:
-
Object
- Object
- SGF::Model::PropertyHandler
- Defined in:
- lib/sgf/model/property_handler.rb
Instance Method Summary collapse
- #handle(model, name, value) ⇒ Object
-
#initialize(method_mappings, misc_properties) ⇒ PropertyHandler
constructor
A new instance of PropertyHandler.
Constructor Details
#initialize(method_mappings, misc_properties) ⇒ PropertyHandler
Returns a new instance of PropertyHandler.
4 5 6 7 |
# File 'lib/sgf/model/property_handler.rb', line 4 def initialize method_mappings, misc_properties @method_mappings = method_mappings @misc_properties = misc_properties end |
Instance Method Details
#handle(model, name, value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sgf/model/property_handler.rb', line 9 def handle model, name, value if @method_mappings.include?(name) model.send(@method_mappings[name], value) true elsif @misc_properties.include?(name) if model.misc_properties[name] model.misc_properties[name] = [model.misc_properties[name], value].flatten else model.misc_properties[name] = value end true end end |