Module: LightServices::Base::ClassMethods
- Included in:
- Service
- Defined in:
- lib/light_services/base.rb
Instance Method Summary collapse
- #attributes(*args) ⇒ Object
- #define_class_attributes(attributes) ⇒ Object
- #execute(method_name, options = {}) ⇒ Object
- #get_attributes ⇒ Object
- #get_execute_method_name ⇒ Object
- #get_execute_method_options ⇒ Object
- #get_returns ⇒ Object
- #get_returns_block ⇒ Object
- #returns(resource, &block) ⇒ Object
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, = {}) @method_name = method_name @execute_options = { if: [:if], fallback: [:fallback] } end |
#get_attributes ⇒ Object
10 11 12 |
# File 'lib/light_services/base.rb', line 10 def get_attributes @attributes || {} end |
#get_execute_method_name ⇒ Object
32 33 34 |
# File 'lib/light_services/base.rb', line 32 def get_execute_method_name @method_name end |
#get_execute_method_options ⇒ Object
36 37 38 |
# File 'lib/light_services/base.rb', line 36 def @execute_options end |
#get_returns ⇒ Object
19 20 21 |
# File 'lib/light_services/base.rb', line 19 def get_returns @returns end |
#get_returns_block ⇒ Object
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 |