class Rectify::Command

Public Class Methods

call(*args, &block) click to toggle source
# File lib/rectify/command.rb, line 24
def self.call(*args, &block)
  event_recorder = EventRecorder.new

  command = new(*args)
  command.subscribe(event_recorder)
  command.evaluate(&block) if block_given?
  command.call

  event_recorder.events
end

Public Instance Methods

evaluate(&block) click to toggle source
# File lib/rectify/command.rb, line 35
def evaluate(&block)
  @caller = eval("self", block.binding, __FILE__, __LINE__)
  instance_eval(&block)
end
method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/rectify/command.rb, line 44
def method_missing(method_name, *args, &block)
  if @caller.respond_to?(method_name, true)
    @caller.send(method_name, *args, &block)
  else
    super
  end
end
respond_to_missing?(method_name, include_private = false) click to toggle source
# File lib/rectify/command.rb, line 52
def respond_to_missing?(method_name, include_private = false)
  @caller.respond_to?(method_name, include_private)
end
transaction(&block) click to toggle source
# File lib/rectify/command.rb, line 40
def transaction(&block)
  ActiveRecord::Base.transaction(&block) if block_given?
end