Module: Gexp::Item
- Included in:
- ItemExample
- Defined in:
- lib/gexp/item.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_event(transition) ⇒ Object
- #around_handlers(fsm_transition, &block) ⇒ Object
- #before_event(transition) ⇒ Object
- #check_handlers(transition) ⇒ Object
- #modify_handlers(transition) ⇒ Object
- #on_error(exception) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gexp/item.rb', line 5 def self.included(base) base.instance_eval do class << self def inherited(sub) sub.instance_eval do include Gexp::Object end end def register @register ||= {} if @register.empty? register = Configuration.for 'register' register.keys.each do |key| @register[key] = Configuration.for(key).to_hash end end @register end def reload_register! @register = {} end end end end |
Instance Method Details
#after_event(transition) ⇒ Object
56 57 58 |
# File 'lib/gexp/item.rb', line 56 def after_event(transition) # TODO: сделать обработку события end |
#around_handlers(fsm_transition, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gexp/item.rb', line 35 def around_handlers(fsm_transition, &block) # объект команды (как параметр к событию) transition = Gexp::Handler::Transition::Builder.new(fsm_transition) self.check_handlers(transition) self.before_event(transition) block.call # выполнение самого перехода self.after_event(transition) self.modify_handlers(transition) rescue => e raise e unless self.on_error(e) end |
#before_event(transition) ⇒ Object
52 53 54 |
# File 'lib/gexp/item.rb', line 52 def before_event(transition) # TODO: сделать обработку события end |
#check_handlers(transition) ⇒ Object
60 61 62 63 64 |
# File 'lib/gexp/item.rb', line 60 def check_handlers(transition) transition.checkers.each { |handler| handler.process(*handler.params) } end |
#modify_handlers(transition) ⇒ Object
66 67 68 69 70 |
# File 'lib/gexp/item.rb', line 66 def modify_handlers(transition) transition.modifiers.each { |handler| handler.process(*handler.params) } end |
#on_error(exception) ⇒ Object
48 49 50 |
# File 'lib/gexp/item.rb', line 48 def on_error(exception) # TODO: Сделать обработку ошибок перехода end |