Class: PyrRules::ModelCreationHandler

Inherits:
ActionHandler show all
Defined in:
app/rules/pyr_rules/model_creation_handler.rb

Instance Attribute Summary

Attributes inherited from ActionHandler

#action, #event

Instance Method Summary collapse

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

#handleObject



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_classObject



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