class NiftyServices::BaseActionService

Public Class Methods

action_name(action_name, options={}) click to toggle source
# File lib/nifty_services/base_action_service.rb, line 4
def self.action_name(action_name, options={})
  define_method :action_name do
    action_name
  end
end

Public Instance Methods

execute() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 10
def execute
  execute_action do
    with_before_and_after_callbacks(:action) do
      # here user can
      with_before_and_after_callbacks(:execute_service_action) do
        execute_service_action
      end

      success_response if valid?
    end
  end
end

Private Instance Methods

action_errors() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 24
def action_errors
  @errors
end
action_name() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 52
def action_name
  not_implemented_exception(__method__)
end
can_execute?() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 28
def can_execute?
  unless can_execute_action?
    return (valid? ? unprocessable_entity_error!(invalid_action_error_key) : false)
  end

  return true
end
can_execute_action?() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 40
def can_execute_action?
  not_implemented_exception(__method__)
end
execute_service_action() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 44
def execute_service_action
  not_implemented_exception(__method__)
end
invalid_action_error_key() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 36
def invalid_action_error_key
  "#{record_error_key}.cant_execute_#{action_name}"
end
record_error_key() click to toggle source
# File lib/nifty_services/base_action_service.rb, line 48
def record_error_key
  not_implemented_exception(__method__)
end