Class: Flexite::ActionService::Result
- Inherits:
-
Object
- Object
- Flexite::ActionService::Result
- Defined in:
- app/services/flexite/action_service/result.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #add_error(name, value) ⇒ Object
- #add_errors(name, values) ⇒ Object
- #data ⇒ Object (also: #record)
- #endpoint ⇒ Object
- #failed? ⇒ Boolean
- #flash ⇒ Object
-
#initialize(options = {}) ⇒ Result
constructor
A new instance of Result.
- #redirect? ⇒ Boolean
- #render? ⇒ Boolean
- #succeed? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Result
Returns a new instance of Result.
4 5 6 7 |
# File 'app/services/flexite/action_service/result.rb', line 4 def initialize( = {}) @options = @errors = ::Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'app/services/flexite/action_service/result.rb', line 2 def @options end |
Instance Method Details
#add_error(name, value) ⇒ Object
31 32 33 |
# File 'app/services/flexite/action_service/result.rb', line 31 def add_error(name, value) @errors[name] << value end |
#add_errors(name, values) ⇒ Object
35 36 37 |
# File 'app/services/flexite/action_service/result.rb', line 35 def add_errors(name, values) @errors[name] += values end |
#data ⇒ Object Also known as: record
25 26 27 |
# File 'app/services/flexite/action_service/result.rb', line 25 def data @options[:data] end |
#endpoint ⇒ Object
39 40 41 |
# File 'app/services/flexite/action_service/result.rb', line 39 def endpoint @options.fetch(:endpoint, {}) end |
#failed? ⇒ Boolean
13 14 15 |
# File 'app/services/flexite/action_service/result.rb', line 13 def failed? !succeed? end |
#flash ⇒ Object
43 44 45 |
# File 'app/services/flexite/action_service/result.rb', line 43 def flash @options.fetch(:flash, {}) end |
#redirect? ⇒ Boolean
21 22 23 |
# File 'app/services/flexite/action_service/result.rb', line 21 def redirect? !render? end |
#render? ⇒ Boolean
17 18 19 |
# File 'app/services/flexite/action_service/result.rb', line 17 def render? @options.fetch(:render, true) end |
#succeed? ⇒ Boolean
9 10 11 |
# File 'app/services/flexite/action_service/result.rb', line 9 def succeed? @options.fetch(:success, true) end |