Class: Faire::Interactor

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/faire/interactor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Interactor

Returns a new instance of Interactor.



8
9
10
# File 'lib/faire/interactor.rb', line 8

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/faire/interactor.rb', line 4

def object
  @object
end

Instance Method Details

#errorsObject



21
22
23
# File 'lib/faire/interactor.rb', line 21

def errors
  @errors ||= object.errors
end

#fail?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/faire/interactor.rb', line 29

def fail?
  errors.any?
end

#resultObject



17
18
19
# File 'lib/faire/interactor.rb', line 17

def result
  @result ||= execute if valid?
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/faire/interactor.rb', line 25

def success?
  errors.empty?
end

#validate_and_executeObject



12
13
14
15
# File 'lib/faire/interactor.rb', line 12

def validate_and_execute
  validate
  result
end