Class: Flexite::ActionService::Result

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {})
  @options = options
  @errors = ::Hash.new { |h, k| h[k] = [] }
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



2
3
4
# File 'app/services/flexite/action_service/result.rb', line 2

def options
  @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

#dataObject Also known as: record



25
26
27
# File 'app/services/flexite/action_service/result.rb', line 25

def data
  @options[:data]
end

#endpointObject



39
40
41
# File 'app/services/flexite/action_service/result.rb', line 39

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

#failed?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/services/flexite/action_service/result.rb', line 13

def failed?
  !succeed?
end

#flashObject



43
44
45
# File 'app/services/flexite/action_service/result.rb', line 43

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

#redirect?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/services/flexite/action_service/result.rb', line 21

def redirect?
  !render?
end

#render?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/services/flexite/action_service/result.rb', line 17

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

#succeed?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'app/services/flexite/action_service/result.rb', line 9

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