Class: ServicePattern::Response
- Inherits:
-
Object
- Object
- ServicePattern::Response
- Defined in:
- lib/service_pattern/response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(args) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Response
Returns a new instance of Response.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/service_pattern/response.rb', line 4 def initialize(args) @errors = args[:errors] || [] @result = args[:result] if args.key?(:success) @success = args.fetch(:success) elsif args.key?(:errors) && @errors.any? @success = false elsif @result @success = true else raise "Couldn't figure out if it was a success" end end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
2 3 4 |
# File 'lib/service_pattern/response.rb', line 2 def errors @errors end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
2 3 4 |
# File 'lib/service_pattern/response.rb', line 2 def result @result end |
Instance Method Details
#success? ⇒ Boolean
19 20 21 |
# File 'lib/service_pattern/response.rb', line 19 def success? @success end |