class ActiveCommand::Command

Public Class Methods

from_json(json) click to toggle source
# File lib/active_command/command.rb, line 11
def self.from_json(json)
  klass = self.new
  klass.from_json(json)
  klass
end

Public Instance Methods

execute() click to toggle source
# File lib/active_command/command.rb, line 39
def execute
  raise NotImplementedError, "#{self.class.name} does not implement an execute method"
end
perform(job_data) click to toggle source
# File lib/active_command/command.rb, line 26
def perform(job_data)
  self.from_json(job_data)
  self.perform_now
end
perform_now() click to toggle source
# File lib/active_command/command.rb, line 31
def perform_now
  if self.valid?
    self.execute
  else
    raise ActiveCommand::CommandNotValidError, self.errors.full_messages
  end
end
run() click to toggle source
# File lib/active_command/command.rb, line 22
def run
  self.class.perform_async self.to_params.to_json
end
to_hash()
Alias for: to_params
to_params() click to toggle source
# File lib/active_command/command.rb, line 17
def to_params
  ActiveSupport::HashWithIndifferentAccess.new(attributes).delete_if { |k, v| v.nil? }
end
Also aliased as: to_hash