Class: ActionService::Base
- Inherits:
-
Object
- Object
- ActionService::Base
- Defined in:
- lib/action_service.rb
Overview
ActionService::Base is the parent class for all services that will be generated.
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #add_error(error_message) ⇒ Object
- #add_errors(*error_messages) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 |
# File 'lib/action_service.rb', line 11 def initialize @errors = [] # contain errors @response = {} # contain the service response data @success = true # flag service execution without any error end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/action_service.rb', line 9 def errors @errors end |
#response ⇒ Object
Returns the value of attribute response.
9 10 11 |
# File 'lib/action_service.rb', line 9 def response @response end |
Instance Method Details
#add_error(error_message) ⇒ Object
21 22 23 24 |
# File 'lib/action_service.rb', line 21 def add_error() @success = false @errors << end |
#add_errors(*error_messages) ⇒ Object
26 27 28 29 30 |
# File 'lib/action_service.rb', line 26 def add_errors(*) @success = false = [0] if [0].is_a? Array @errors += end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/action_service.rb', line 17 def success? @success end |