Module: Sidestate::Hook
- Defined in:
- lib/sidestate/hook.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sidestate/hook.rb', line 2 def self.included(base) base.instance_eval do extend Sidestate::Hook::ClassMethods has_many aasm_state_collection after_create :save_aasm_state_object_for_new_record after_update :save_aasm_state_object define_method(aasm_state_object) do aasm_state_collection.last end end base.aasm_state_class.instance_eval do belongs_to base.name.underscore.to_sym end end |
Instance Method Details
#next_states ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/sidestate/hook.rb', line 34 def next_states self.class.aasm_events.collect { |name, event| event.transitions_from_state(aasm_current_state) }.flatten.collect { |transition| Array(transition.to) }.flatten end |