module Riveter::Command

Public Class Methods

failure_notice() click to toggle source
# File lib/riveter/command.rb, line 23
def failure_notice
  I18n.translate(
    :failure,
    :scope => [i18n_scope, :notices, command_name.i18n_key],
    :default => "Failed to execute #{command_name.human}."
  )
end
i18n_scope() click to toggle source
# File lib/riveter/command.rb, line 11
def i18n_scope
  :commands
end
submit(*args) click to toggle source
# File lib/riveter/command.rb, line 31
def submit(*args)
  new().submit(*args)
end
success_notice() click to toggle source
# File lib/riveter/command.rb, line 15
def success_notice
  I18n.translate(
    :success,
    :scope => [i18n_scope, :notices, command_name.i18n_key],
    :default => "Successfully executed #{command_name.human}."
  )
end

Public Instance Methods

submit(*args) click to toggle source
# File lib/riveter/command.rb, line 39
def submit(*args)
  params = args.extract_options!

  # filter and clean params before applying
  apply_params(
    clean_params(
      filter_params(params)
    )
  )

  # perform validations, and proceed if valid
  return false unless self.can_perform?

  # all good, perform the action
  self.perform(*args)
end

Protected Instance Methods

perform(*args) click to toggle source
# File lib/riveter/command.rb, line 58
def perform(*args)
  # resolve for the registered service for this command
  service_class = Service::Base.resolve!(self.class)
  # create an instance and invoke perform
  service = service_class.new()
  service.perform(self, *args)
end