class Enum::Transitions::DSL::Proxy

Public Class Methods

embed(states) click to toggle source

@param states [Array<String>]

# File lib/enum/transitions/dsl/proxy.rb, line 8
def self.embed(states)
  Class.new(self) do
    states.each do |state|
      define_method(state) { state }
    end
  end
end
new(config) click to toggle source

@param config [Enum::Transitions::Configuration]

# File lib/enum/transitions/dsl/proxy.rb, line 17
def initialize(config)
  @config = config
end

Public Instance Methods

after_entering(*states, &block) click to toggle source
# File lib/enum/transitions/dsl/proxy.rb, line 55
def after_entering(*states, &block)
  states.each do |state|
    @config.callbacks[entering_event(state)] << [:after, block]
  end
end
after_leaving(*states, &block) click to toggle source
# File lib/enum/transitions/dsl/proxy.rb, line 43
def after_leaving(*states, &block)
  states.each do |state|
    @config.callbacks[leaving_event(state)] << [:after, block]
  end
end
before_entering(*states, &block) click to toggle source
# File lib/enum/transitions/dsl/proxy.rb, line 49
def before_entering(*states, &block)
  states.each do |state|
    @config.callbacks[entering_event(state)] << [:before, block]
  end
end
before_leaving(*states, &block) click to toggle source
# File lib/enum/transitions/dsl/proxy.rb, line 37
def before_leaving(*states, &block)
  states.each do |state|
    @config.callbacks[leaving_event(state)] << [:before, block]
  end
end