Sha256: 858013585f293b52f9c711171ce4acd2a9725fba8515b574e151682256fc90e3

Contents?: true

Size: 1.63 KB

Versions: 26

Compression:

Stored size: 1.63 KB

Contents

class Guardian
  include AASM

  aasm do
    state :alpha, :initial => true
    state :beta

    event :use_one_guard_that_succeeds do
      transitions :from => :alpha, :to => :beta, :guard => :succeed
    end
    event :use_one_guard_that_fails do
      transitions :from => :alpha, :to => :beta, :guard => :fail
    end

    event :use_guards_that_succeed do
      transitions :from => :alpha, :to => :beta, :guards => [:succeed, :another_succeed]
    end
    event :use_guards_where_the_first_fails do
      transitions :from => :alpha, :to => :beta, :guards => [:succeed, :fail]
    end
    event :use_guards_where_the_second_fails do
      transitions :from => :alpha, :to => :beta, :guards => [:fail, :succeed]
    end

    event :use_event_guards_that_succeed, :guards => [:succeed, :another_succeed] do
      transitions :from => :alpha, :to => :beta
    end
    event :use_event_and_transition_guards_that_succeed, :guards => [:succeed, :another_succeed] do
      transitions :from => :alpha, :to => :beta, :guards => [:more_succeed]
    end
    event :use_event_guards_where_the_first_fails, :guards => [:succeed, :fail] do
      transitions :from => :alpha, :to => :beta
    end
    event :use_event_guards_where_the_second_fails, :guards => [:fail, :succeed] do
      transitions :from => :alpha, :to => :beta, :guard => :another_succeed
    end
    event :use_event_and_transition_guards_where_third_fails, :guards => [:succeed, :another_succeed] do
      transitions :from => :alpha, :to => :beta, :guards => [:fail]
    end
  end

  def fail; false; end

  def succeed; true; end
  def another_succeed; true; end
  def more_succeed; true; end

end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
aasm-4.5.1 spec/models/guardian.rb
aasm-4.5.0 spec/models/guardian.rb
aasm-4.4.1 spec/models/guardian.rb
aasm-4.4.0 spec/models/guardian.rb
aasm-4.3.0 spec/models/guardian.rb
aasm-4.2.0 spec/models/guardian.rb
aasm-4.1.1 spec/models/guardian.rb
aasm-4.1.0 spec/models/guardian.rb
aasm-4.0.8 spec/models/guardian.rb
aasm-4.0.7 spec/models/guardian.rb
aasm-4.0.6 spec/models/guardian.rb
aasm-4.0.5 spec/models/guardian.rb
aasm-4.0.4 spec/models/guardian.rb
aasm-4.0.3 spec/models/guardian.rb
aasm-4.0.2 spec/models/guardian.rb
aasm-4.0.1 spec/models/guardian.rb
aasm-4.0.0 spec/models/guardian.rb
aasm-3.4.0 spec/models/guardian.rb
aasm-3.3.3 spec/models/guardian.rb
aasm-3.3.2 spec/models/guardian.rb