Class: Flexite::ActionService::Result
- Inherits:
-
Object
- Object
- Flexite::ActionService::Result
- Defined in:
- app/services/flexite/action_service/result.rb
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.
2 3 4 5 |
# File 'app/services/flexite/action_service/result.rb', line 2 def initialize( = {}) @options = @errors = Hash.new { |h, k| h[k] = [] } end |
Instance Method Details
#add_error(name, value) ⇒ Object
29 30 31 |
# File 'app/services/flexite/action_service/result.rb', line 29 def add_error(name, value) @errors[name] << value end |
#add_errors(name, values) ⇒ Object
33 34 35 |
# File 'app/services/flexite/action_service/result.rb', line 33 def add_errors(name, values) @errors[name] += values end |
#data ⇒ Object Also known as: record
23 24 25 |
# File 'app/services/flexite/action_service/result.rb', line 23 def data @options[:data] end |
#endpoint ⇒ Object
37 38 39 |
# File 'app/services/flexite/action_service/result.rb', line 37 def endpoint @options.fetch(:endpoint, {}) end |
#failed? ⇒ Boolean
11 12 13 |
# File 'app/services/flexite/action_service/result.rb', line 11 def failed? !succeed? end |
#flash ⇒ Object
41 42 43 |
# File 'app/services/flexite/action_service/result.rb', line 41 def flash @options.fetch(:flash, {}) end |
#redirect? ⇒ Boolean
19 20 21 |
# File 'app/services/flexite/action_service/result.rb', line 19 def redirect? !render? end |
#render? ⇒ Boolean
15 16 17 |
# File 'app/services/flexite/action_service/result.rb', line 15 def render? @options.fetch(:render, true) end |
#succeed? ⇒ Boolean
7 8 9 |
# File 'app/services/flexite/action_service/result.rb', line 7 def succeed? @options.fetch(:succeed, true) end |