class AASM::InstanceBase
def states(options={}, *args)
def states(options={}, *args) if options.has_key?(:permitted) selected_events = events({:permitted => options[:permitted]}, *args) # An array of arrays. Each inner array represents the transitions that # transition from the current state for an event event_transitions = selected_events.map {|e| e.transitions_from_state(current_state) } # An array of :to transition states to_state_names = event_transitions.map do |transitions| return nil if transitions.empty? # Return the :to state of the first transition that is allowed (or not) or nil if options[:permitted] transition = transitions.find { |t| t.allowed?(@instance, *args) } else transition = transitions.find { |t| !t.allowed?(@instance, *args) } end transition ? transition.to : nil end.flatten.compact.uniq # Select states that are in to_state_names @instance.class.aasm(@name).states.select {|s| to_state_names.include?(s.name)} else @instance.class.aasm(@name).states end end