Class: PyrRules::ModelCreationHandler
- Inherits:
-
ActionHandler
- Object
- ActionHandler
- PyrRules::ModelCreationHandler
- Defined in:
- app/rules/pyr_rules/model_creation_handler.rb
Instance Attribute Summary
Attributes inherited from ActionHandler
Instance Method Summary collapse
- #handle ⇒ Object
- #model_class ⇒ Object
-
#set_model_props(m) ⇒ Object
Subclassers add your mappings here.
Methods inherited from ActionHandler
_add_needs_and_recurse, action_listing, configuration, #eval_template, #initialize, #method_missing, needs, reload_configuration, template
Constructor Details
This class inherits a constructor from PyrRules::ActionHandler
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PyrRules::ActionHandler
Instance Method Details
#handle ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/rules/pyr_rules/model_creation_handler.rb', line 5 def handle super model_instance = model_class.new if model_instance.respond_to? :user= model_instance.user = owner end set_model_props model_instance puts "Saving instance #{model_instance.attributes}" model_instance.save! end |
#model_class ⇒ Object
21 22 23 |
# File 'app/rules/pyr_rules/model_creation_handler.rb', line 21 def model_class raise "Subclassers please implement model_class" end |
#set_model_props(m) ⇒ Object
Subclassers add your mappings here
17 18 19 |
# File 'app/rules/pyr_rules/model_creation_handler.rb', line 17 def set_model_props(m) end |