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 Method Summary collapse
- #add_error(error_message) ⇒ Object
- #add_errors(*error_messages) ⇒ Object
- #add_errors_array(error_messages_array) ⇒ Object
- #errors ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #response ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 |
# File 'lib/action_service.rb', line 10 def initialize @errors = [] # contain errors @response = {} # contain the service response data @success = true # flag service execution without any error end |
Instance Method Details
#add_error(error_message) ⇒ Object
28 29 30 31 |
# File 'lib/action_service.rb', line 28 def add_error() @success = false @errors << end |
#add_errors(*error_messages) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/action_service.rb', line 33 def add_errors(*) @success = false if [0].kind_of?(Array) # called using array add_errors_array([0]) else @errors += end end |
#add_errors_array(error_messages_array) ⇒ Object
43 44 45 46 |
# File 'lib/action_service.rb', line 43 def add_errors_array() @success = false @errors += end |
#errors ⇒ Object
16 17 18 |
# File 'lib/action_service.rb', line 16 def errors @errors end |
#response ⇒ Object
20 21 22 |
# File 'lib/action_service.rb', line 20 def response @response end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/action_service.rb', line 24 def success? @success end |