Class: Transactor::Actor

Inherits:
Object
  • Object
show all
Defined in:
lib/transactor/actor.rb

Direct Known Subclasses

Improv::Actor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/transactor/actor.rb', line 45

def method_missing(meth, *args, &block)
  if props.respond_to?(meth)
    props.send meth, *args, &block
  else
    super
  end
end

Instance Attribute Details

#propsObject (readonly)

Returns the value of attribute props.



3
4
5
# File 'lib/transactor/actor.rb', line 3

def props
  @props
end

Class Method Details

.perform(*args, &block) ⇒ Object



6
7
8
# File 'lib/transactor/actor.rb', line 6

def perform(*args, &block)
  new(*args).perform(&block)
end

.rollback_on_failure!Object



10
11
12
# File 'lib/transactor/actor.rb', line 10

def rollback_on_failure!
  @rollback_on_failure = true
end

.rollback_on_failure?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/transactor/actor.rb', line 14

def rollback_on_failure?
  return Transactor.configuration.rollback_failed_actors if @rollback_on_failure.nil?
  @rollback_on_failure
end

Instance Method Details

#perform(&block) ⇒ Object



29
30
31
# File 'lib/transactor/actor.rb', line 29

def perform(&block)
  raise PerformNotImplemented, "#{self.class.name}##{__method__} has not been implemented"
end

#respond_to_missing?(meth, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/transactor/actor.rb', line 53

def respond_to_missing?(meth, include_private=false)
  props.respond_to?(meth, include_private)
end

#rollback(&block) ⇒ Object



33
34
35
# File 'lib/transactor/actor.rb', line 33

def rollback(&block)
  raise RollbackNotImplemented, "#{self.class.name}##{__method__} has not been implemented"
end

#rollback_on_failure!Object



20
21
22
# File 'lib/transactor/actor.rb', line 20

def rollback_on_failure!
  @rollback_on_failure = true
end

#rollback_on_failure?Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/transactor/actor.rb', line 24

def rollback_on_failure?
  return self.class.rollback_on_failure? if @rollback_on_failure.nil?
  @rollback_on_failure
end

#stateObject



37
38
39
# File 'lib/transactor/actor.rb', line 37

def state
  props.to_h
end

#to_sObject



41
42
43
# File 'lib/transactor/actor.rb', line 41

def to_s
  "#{self.class.name} #{state.to_s}"
end