Skip to content

Commit

Permalink
Hide delegation on state names
Browse files Browse the repository at this point in the history
  • Loading branch information
GMorris-professional committed Feb 16, 2023
1 parent 2e952ff commit 47a6265
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/aasm/instance_base.rb
Expand Up @@ -57,6 +57,10 @@ def states(options={}, *args)
end
end

def state_names
self.states.map(&:name)
end

def events(options={}, *args)
state = options[:state] || current_state
events = @instance.class.aasm(@name).events.select {|e| e.transitions_from_state?(state) }
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/states_on_one_line_example_spec.rb
Expand Up @@ -13,4 +13,10 @@
expect(example.aasm(:one_line).states.map(&:name)).to eq [:initial, :first, :second]
end
end

describe 'states_names' do
it 'should have all 3 states defined' do
expect(example.aasm(:one_line).state_names).to eq [:initial, :first, :second]
end
end
end

0 comments on commit 47a6265

Please sign in to comment.