class ApiService::ActionState

Attributes

response[R]

Public Class Methods

new(initial_state = {}) click to toggle source
# File lib/api_service/action_state.rb, line 9
def initialize(initial_state = {})
  @response = nil
  @state = initial_state
  @error_manager = ErrorManager.new
end

Public Instance Methods

action() click to toggle source
# File lib/api_service/action_state.rb, line 20
def action
  @current_action
end
add_current_action(action, is_last = false) click to toggle source
# File lib/api_service/action_state.rb, line 15
def add_current_action(action, is_last = false)
  @current_action = action
  @is_current_action_last = is_last
end
build_failed_response() click to toggle source
# File lib/api_service/action_state.rb, line 40
def build_failed_response
  @response = FailedResult.new(self)
end
errors() click to toggle source
# File lib/api_service/action_state.rb, line 28
def errors
  @error_manager
end
fetch(field) click to toggle source
# File lib/api_service/action_state.rb, line 36
def fetch(field)
  @state[field]
end
set(field, value) click to toggle source
# File lib/api_service/action_state.rb, line 32
def set(field, value)
  @state[field] = value
end
success(response = {}, options = {}) click to toggle source
# File lib/api_service/action_state.rb, line 44
def success(response = {}, options = {})
  return unless @is_current_action_last
  @response = SuccessfulResult.new(response, self, options)
end
valid?() click to toggle source
# File lib/api_service/action_state.rb, line 24
def valid?
  !errors.any?
end