Class: LightServices::Service

Inherits:
Object
  • Object
show all
Extended by:
Base::ClassMethods
Includes:
ActiveModel::Validations, Base::InstanceMethods
Defined in:
lib/light_services/service.rb

Instance Method Summary collapse

Methods included from Base::ClassMethods

attributes, define_class_attributes, execute, get_attributes, get_execute_method_name, get_execute_method_options, get_returns, get_returns_block, returns

Methods included from Base::InstanceMethods

#attributes, #execute_method_name, #execute_method_options, #initialize_class_attributes, #initialize_returns_attribute, #returns, #returns_block, #returns_name, #setup_returns

Constructor Details

#initialize(*args) ⇒ Service

Returns a new instance of Service.



11
12
13
14
15
16
# File 'lib/light_services/service.rb', line 11

def initialize(*args)
  validate_arguments(args)
  initialize_class_attributes(args)
  initialize_returns_attribute if has_returns?
  setup_returns if returns_block
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
# File 'lib/light_services/service.rb', line 18

def call
  if has_conditional?
    executed_method_return = validate_conditional
  else
    executed_method_return = send( execute_method_name )
  end
  
  has_returns? ? instance_variable_get("@#{ returns_name }") : executed_method_return
end