Module: Workflow::Join::ActiveRecord::PendingCallbacks
- Included in:
- Workflow::Join::ActiveRecord
- Defined in:
- lib/workflow/join/active_record/pending_callbacks.rb
Overview
table.column :workflow_pending_callbacks, :string
Instance Method Summary collapse
- #pending_callback!(value) ⇒ Object
- #pending_callbacks ⇒ Object
- #pending_callbacks!(value) ⇒ Object
- #pending_callbacks? ⇒ Boolean
Instance Method Details
#pending_callback!(value) ⇒ Object
25 26 27 |
# File 'lib/workflow/join/active_record/pending_callbacks.rb', line 25 def pending_callback!(value) pending_callbacks!(pending_callbacks | [value]) end |
#pending_callbacks ⇒ Object
6 7 8 9 10 11 |
# File 'lib/workflow/join/active_record/pending_callbacks.rb', line 6 def pending_callbacks workflow_pending_callbacks.to_s.split(';').map do |wpc| c, id = wpc.split(',') Kernel.const_get(c).find(id) rescue nil end.compact end |
#pending_callbacks!(value) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/workflow/join/active_record/pending_callbacks.rb', line 13 def pending_callbacks!(value) pcs = case value when Array then value.map { |instance| [instance.class.name, instance.id].join(',') }.join(';') when String, Symbol then value.to_s end update_column :workflow_pending_callbacks, pcs end |
#pending_callbacks? ⇒ Boolean
21 22 23 |
# File 'lib/workflow/join/active_record/pending_callbacks.rb', line 21 def pending_callbacks? !pending_callbacks.empty? end |