Module: LightServices::Base::ClassMethods

Included in:
Service
Defined in:
lib/light_services/base.rb

Instance Method Summary collapse

Instance Method Details

#attributes(*args) ⇒ Object



5
6
7
8
# File 'lib/light_services/base.rb', line 5

def attributes(*args)
  define_class_attributes(args)
  @attributes = args
end

#define_class_attributes(attributes) ⇒ Object



40
41
42
43
44
# File 'lib/light_services/base.rb', line 40

def define_class_attributes(attributes)
  attributes.map do |attr_name|
    send(:attr_reader, attr_name)
  end
end

#execute(method_name, options = {}) ⇒ Object



27
28
29
30
# File 'lib/light_services/base.rb', line 27

def execute(method_name, options = {})
  @method_name     = method_name
  @execute_options = { if: options[:if], fallback: options[:fallback] }
end

#get_attributesObject



10
11
12
# File 'lib/light_services/base.rb', line 10

def get_attributes
  @attributes || {}
end

#get_execute_method_nameObject



32
33
34
# File 'lib/light_services/base.rb', line 32

def get_execute_method_name
  @method_name
end

#get_execute_method_optionsObject



36
37
38
# File 'lib/light_services/base.rb', line 36

def get_execute_method_options
  @execute_options
end

#get_returnsObject



19
20
21
# File 'lib/light_services/base.rb', line 19

def get_returns
  @returns
end

#get_returns_blockObject



23
24
25
# File 'lib/light_services/base.rb', line 23

def get_returns_block
  @returns_block
end

#returns(resource, &block) ⇒ Object



14
15
16
17
# File 'lib/light_services/base.rb', line 14

def returns(resource, &block)
  @returns = resource
  @returns_block = block if block_given?
end