Module: CommandExtension::AfterCommit::ClassMethods

Defined in:
lib/command_extension/after_commit.rb

Instance Method Summary collapse

Instance Method Details

#after_commit(method = nil, &block) ⇒ Object



61
62
63
64
65
# File 'lib/command_extension/after_commit.rb', line 61

def after_commit(method = nil, &block)
  after_commit_queue << method if method
  after_commit_queue << block if block
  true
end

#after_commit_queueObject



57
58
59
# File 'lib/command_extension/after_commit.rb', line 57

def after_commit_queue
  @after_commit_queue ||= []
end

#run_after_commit_queue(instance) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/command_extension/after_commit.rb', line 67

def run_after_commit_queue(instance)
  after_commit_queue.each do |m|
    case m
    when Symbol, String
      instance.__send__(m)
    else
      instance.instance_eval(m)
    end
  end
end