2024-03-04 16:49:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module AasmEventsConcern
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
# Todos los eventos de la máquina de estados
|
|
|
|
#
|
|
|
|
# @return [Array<Symbol>]
|
|
|
|
def self.events
|
|
|
|
aasm.events.map(&:name) - self::IGNORED_EVENTS
|
|
|
|
end
|
2024-03-04 16:59:01 +00:00
|
|
|
|
2024-03-04 20:45:16 +00:00
|
|
|
# Encuentra todos los eventos que se pueden ejecutar con el filtro
|
|
|
|
# actual.
|
|
|
|
#
|
|
|
|
# @return [Array<Symbol>]
|
|
|
|
def self.transitionable_events(current_state)
|
|
|
|
self.events.select do |event|
|
|
|
|
aasm.events.find { |x| x.name == event }.transitions_from_state? current_state
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-03-04 16:59:01 +00:00
|
|
|
# Todos los estados de la máquina de estados
|
|
|
|
#
|
|
|
|
# @return [Array<Symbol>]
|
|
|
|
def self.states
|
|
|
|
aasm.states.map(&:name) - self::IGNORED_STATES
|
|
|
|
end
|
2024-03-04 16:49:07 +00:00
|
|
|
end
|
|
|
|
end
|