Class: Workflowable::Action
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Workflowable::Action
- Defined in:
- app/models/workflowable/action.rb
Instance Method Summary collapse
- #action_plugin_name ⇒ Object
- #action_plugin_options ⇒ Object
- #autocomplete(field_type, value, options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
- #available_options(options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
- #reject_blank_values ⇒ Object
- #run(options = {}, workflow, object, current_stage, next_stage, user) ⇒ Object
- #validate_action_plugin ⇒ Object
- #validate_options(options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
Instance Method Details
#action_plugin_name ⇒ Object
108 109 110 |
# File 'app/models/workflowable/action.rb', line 108 def action_plugin_name ("Workflowable::Actions::"+action_plugin).constantize.name end |
#action_plugin_options ⇒ Object
103 104 105 |
# File 'app/models/workflowable/action.rb', line 103 def ("Workflowable::Actions::"+action_plugin).constantize. end |
#autocomplete(field_type, value, options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
46 47 48 |
# File 'app/models/workflowable/action.rb', line 46 def autocomplete(field_type, value, ={}, workflow=nil, object=nil, current_stage=nil, next_stage=nil, user=nil) ("Workflowable::Actions::"+action_plugin).constantize.autocomplete(field_type, value, , workflow, object, current_stage, next_stage, user) end |
#available_options(options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'app/models/workflowable/action.rb', line 67 def (={}, workflow=nil, object=nil, current_stage=nil, next_stage=nil, user=nil) ||={} # value_options = options.with_indifferent_access.deep_dup.each{|k1,v1| # v1.reject!{|k2,v2| k2!= "value" || v2.blank?}; # v1[:user_specified]=true; # } # default_options = options.with_indifferent_access.deep_dup.each{ |k1,v1| # v1.reject!{|k2,v2| k2!= "default" || v2.blank? } # } = .with_indifferent_access.each{|k1,v1| v1.reject{|k2,v2| k2 != "value" || v2.blank?}; v1[:user_specified]=true; } = .with_indifferent_access.each{ |k1,v1| v1.reject{|k2,v2| k2 != "default" || v2.blank? } } = self..with_indifferent_access.deep_merge() = .with_indifferent_access.deep_merge() if(action_plugin) = ("Workflowable::Actions::"+action_plugin).constantize.(, workflow, object, current_stage, next_stage, user) else = {} end end |
#reject_blank_values ⇒ Object
30 31 32 33 |
# File 'app/models/workflowable/action.rb', line 30 def reject_blank_values .each{|k,v| v.reject!{ |k,v| v.blank? }} .reject!{|k,v| v.blank?} end |
#run(options = {}, workflow, object, current_stage, next_stage, user) ⇒ Object
51 52 53 54 55 56 |
# File 'app/models/workflowable/action.rb', line 51 def run(={}, workflow, object, current_stage, next_stage, user) ||={} plugin = ("Workflowable::Actions::"+action_plugin).constantize#("Workflowable::Actions::" + self.action_plugin.to_s).constantize plugin.new(self.(), workflow, object, current_stage, next_stage, user).run end |
#validate_action_plugin ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/workflowable/action.rb', line 35 def validate_action_plugin begin if(Workflowable::Actions.constants.include?(action_plugin.to_sym)) #if(Workflowable::Actions::Action.subclasses.include?(("Workflowable::Actions::"+action_plugin).constantize)) return true end rescue end errors.add :action_plugin, "is invalid" end |
#validate_options(options = {}, workflow = nil, object = nil, current_stage = nil, next_stage = nil, user = nil) ⇒ Object
59 60 61 62 63 64 |
# File 'app/models/workflowable/action.rb', line 59 def (={}, workflow=nil, object=nil, current_stage=nil, next_stage=nil, user=nil) plugin = ("Workflowable::Actions::"+action_plugin).constantize#("Workflowable::Actions::" + self.action_plugin.to_s).constantize results = plugin.new(self.(), workflow, object, current_stage, next_stage, user). return results end |