Class: Wco::OfficeAction
- Inherits:
-
Object
- Object
- Wco::OfficeAction
- Includes:
- Mongoid::Document, Mongoid::Paranoia, Mongoid::Timestamps
- Defined in:
- app/models/wco/office_action.rb
Constant Summary collapse
- STATUS_ACTIVE =
'active'- STATUS_INACTIVE =
'inactive'- STATUSS =
[ STATUS_ACTIVE, STATUS_INACTIVE ]
Instance Attribute Summary collapse
-
#deactivate ⇒ Object
Returns the value of attribute deactivate.
Instance Method Summary collapse
Instance Attribute Details
#deactivate ⇒ Object
Returns the value of attribute deactivate.
23 24 25 |
# File 'app/models/wco/office_action.rb', line 23 def deactivate @deactivate end |
Instance Method Details
#do_run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/wco/office_action.rb', line 28 def do_run @oa = self @oa.update!({ status: STATUS_INACTIVE }) @oat = @oa.office_action_template begin eval( @oa.tmpl.action_exe ) rescue => err puts! err, "Wco::OfficeAction#do_run" ::ExceptionNotifier.notify_exception( err, data: { office_action: self } ) end if @oa.deactivate ; # nothing else # schedule next actions & update the action @oa.tmpl.ties.each do |tie| next_oa = self.class.find_or_initialize_by({ office_action_template_id: tie.next_tmpl.id, }) next_oa.perform_at = eval(tie.next_at_exe) next_oa.status = STATUS_ACTIVE next_oa.save! end end end |
#tmpl ⇒ Object
14 15 16 |
# File 'app/models/wco/office_action.rb', line 14 def tmpl office_action_template end |
#to_s ⇒ Object
55 56 57 |
# File 'app/models/wco/office_action.rb', line 55 def to_s slug end |