Sha256: e43f819838e13da3c73bfd244a5488c40a623d8682953b1c5db5114e7696fb75

Contents?: true

Size: 863 Bytes

Versions: 32

Compression:

Stored size: 863 Bytes

Contents

module Callbacks
  class PrivateMethodMultiple
    include AASM

    def initialize(options={})
      @fail_event_guard = options[:fail_event_guard]
      @fail_transition_guard = options[:fail_transition_guard]
      @log = options[:log]
      reset_data
    end

    def reset_data
      @data = []
    end

    def data
      @data.join(' ')
    end

    aasm(:left) do
      state :open, :initial => true
      state :closed

      event :close, :after => :after_event do
        transitions :to => :closed, :from => [:open]
      end

      event :open, :after => :after_event do
        transitions :to => :open, :from => :closed
      end
    end

    def log(text)
      @data << text
      puts text if @log
    end

    def aasm_write_state(*args); log('aasm_write_state'); true; end

    private

    def after_event; log('after_event'); end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
aasm-4.10.1 spec/models/callbacks/private_method_multiple.rb
aasm-4.10.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.9.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.8.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.7.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.6.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.5.2 spec/models/callbacks/private_method_multiple.rb
aasm-4.5.1 spec/models/callbacks/private_method_multiple.rb
aasm-4.5.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.4.1 spec/models/callbacks/private_method_multiple.rb
aasm-4.4.0 spec/models/callbacks/private_method_multiple.rb
aasm-4.3.0 spec/models/callbacks/private_method_multiple.rb