Class: Flexite::ActionService::Result

Inherits:
Object
  • Object
show all
Defined in:
app/services/flexite/action_service/result.rb

Instance Method Summary collapse

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 = {})
  @options = 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

#dataObject Also known as: record



23
24
25
# File 'app/services/flexite/action_service/result.rb', line 23

def data
  @options[:data]
end

#endpointObject



37
38
39
# File 'app/services/flexite/action_service/result.rb', line 37

def endpoint
  @options.fetch(:endpoint, {})
end

#failed?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/services/flexite/action_service/result.rb', line 11

def failed?
  !succeed?
end

#flashObject



41
42
43
# File 'app/services/flexite/action_service/result.rb', line 41

def flash
  @options.fetch(:flash, {})
end

#redirect?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/services/flexite/action_service/result.rb', line 19

def redirect?
  !render?
end

#render?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/services/flexite/action_service/result.rb', line 15

def render?
  @options.fetch(:render, true)
end

#succeed?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'app/services/flexite/action_service/result.rb', line 7

def succeed?
  @options.fetch(:succeed, true)
end