class Progressive::Specification::State

Attributes

events[R]

Public Class Methods

new(&block) click to toggle source
# File lib/progressive/specification.rb, line 6
def initialize(&block)
  @events = ActiveSupport::HashWithIndifferentAccess.new
  return unless block.present?
  instance_eval(&block)
end

Public Instance Methods

event(*args) click to toggle source

Public: Defines events

args - Can either be symbol (:potential) or hash (:archive => :archived)

Returns Progression::Specification::Event

# File lib/progressive/specification.rb, line 17
def event(*args)
  name, to = args.first.is_a?(Symbol) ? args.first : args.first.to_a.flatten
  @events[name.to_sym] = Event.new(name, to)
end
event?(state) click to toggle source

Public: Determine if a given event exists.

state - Event name to check for.

Returns true if event exists, false if not.

# File lib/progressive/specification.rb, line 27
def event?(state)
  @events.key?(state)
end