Class: NiftyServices::BaseActionService

Inherits:
BaseService show all
Defined in:
lib/nifty_services/base_action_service.rb

Constant Summary

Constants inherited from BaseService

NiftyServices::BaseService::CALLBACKS

Instance Attribute Summary

Attributes inherited from BaseService

#errors, #logger, #options, #response_status, #response_status_code

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#add_error, #callback_fired?, concern, #default_logger, define_error_response_method, #executed?, #fail?, #initialize, #option_disabled?, #option_enabled?, #option_exists?, #register_callback, register_callback, register_callback_action, #register_callback_action, register_error_response_method, #success?, #valid?

Constructor Details

This class inherits a constructor from NiftyServices::BaseService

Class Method Details

.action_name(action_name, options = {}) ⇒ Object



4
5
6
7
8
# 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

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
# 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