Class: Gexp::Handler::Transition::Builder

Inherits:
Gexp::Handler::Transition show all
Defined in:
lib/gexp/handler/transition/builder.rb

Overview

Возвращает обработчики в зависимости от перехода FSM (StateMachine)

Instance Attribute Summary

Attributes inherited from Gexp::Handler::Transition

#object, #provider, #subject, #transition

Instance Method Summary collapse

Methods inherited from Gexp::Handler::Transition

#actor_support?, #config, #handlers, #initialize, namespaces, #produce

Constructor Details

This class inherits a constructor from Gexp::Handler::Transition

Instance Method Details

#checkersObject



47
48
49
# File 'lib/gexp/handler/transition/builder.rb', line 47

def checkers
  transitions(:check)
end

#conf_handlers(last_key) ⇒ Object

Возвращает конфиги для создания обработчиков



21
22
23
24
25
26
27
# File 'lib/gexp/handler/transition/builder.rb', line 21

def conf_handlers(last_key)
  from        = self.transition.from_name
  to          = self.transition.to_name
  from_branch = self.config.to_hash[:states][:states][from] || {}

  configs     = (from_branch[to] || {})[last_key] || []
end

#events(last_key) ⇒ Object

XXX: метод не используется тк определение событий хранит только информацию по переходам



12
13
14
15
# File 'lib/gexp/handler/transition/builder.rb', line 12

def events(last_key)
  event = self.config.to_hash[:states][:events][@transition.event.to_sym]
  (event || {})[last_key] || []
end

#modifiersObject



51
52
53
# File 'lib/gexp/handler/transition/builder.rb', line 51

def modifiers
  transitions(:modify)
end

#transitions(last_key) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gexp/handler/transition/builder.rb', line 29

def transitions(last_key)
  conf = conf_handlers(last_key)
  type = last_key == :check ? :checkers : :modifiers

  observers = conf.map do |params|

    producer = Gexp::Handler::Producer.new(params, type, { 
      object: self.object,
      subject: self.subject,
      provider: self.provider,
    })

    producer.emit
  end

  observers
end