1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

aasm_human_event_name is deprecated, use aasm.human_event_name instead

This commit is contained in:
Thorsten Böttger 2014-11-16 22:59:35 +01:00
parent 7f3c08199b
commit ef70ac53d9
4 changed files with 21 additions and 8 deletions

View file

@ -1,5 +1,9 @@
# CHANGELOG # CHANGELOG
## 4.1.0 (not yet released)
* `aasm_human_event_name` is deprecated, use `aasm.human_event_name` instead
## 4.0.0 ## 4.0.0
* support `if` and `unless` guard syntax: (see [issue #179](https://github.com/aasm/aasm/issues/179) and [issue #181](https://github.com/aasm/aasm/issues/181)), thanks to [@bigtunacan](https://github.com/bigtunacan) * support `if` and `unless` guard syntax: (see [issue #179](https://github.com/aasm/aasm/issues/179) and [issue #181](https://github.com/aasm/aasm/issues/181)), thanks to [@bigtunacan](https://github.com/bigtunacan)

View file

@ -1,5 +1,8 @@
module AASM module AASM
# provide a state machine for the including class
# make sure to load class methods as well
# initialize persistence for the state machine
def self.included(base) #:nodoc: def self.included(base) #:nodoc:
base.extend AASM::ClassMethods base.extend AASM::ClassMethods
@ -26,9 +29,10 @@ module AASM
@aasm @aasm
end end
# aasm.event(:event_name).human? # deprecated, remove in version 4.1
def aasm_human_event_name(event) # event_name? def aasm_human_event_name(event) # event_name?
AASM::Localizer.new.human_event_name(self, event) warn '[DEPRECATION] AASM: aasm_human_event_name is deprecated, use aasm.human_event_name instead'
aasm.human_event_name(event)
end end
end # ClassMethods end # ClassMethods

View file

@ -85,6 +85,11 @@ module AASM
@state_machine.events.values @state_machine.events.values
end end
# aasm.event(:event_name).human?
def human_event_name(event) # event_name?
AASM::Localizer.new.human_event_name(@klass, event)
end
def states_for_select def states_for_select
states.map { |state| state.for_select } states.map { |state| state.for_select }
end end

View file

@ -67,13 +67,13 @@ describe AASM::Localizer, "new style" do
end end
end end
context 'aasm_human_event_name' do context 'aasm.human_event_name' do
it 'should return translated event name' do it 'should return translated event name' do
expect(LocalizerTestModel.aasm_human_event_name(:close)).to eq("Let's close it!") expect(LocalizerTestModel.aasm.human_event_name(:close)).to eq("Let's close it!")
end end
it 'should return humanized event name' do it 'should return humanized event name' do
expect(LocalizerTestModel.aasm_human_event_name(:open)).to eq("Open") expect(LocalizerTestModel.aasm.human_event_name(:open)).to eq("Open")
end end
end end
end end
@ -102,13 +102,13 @@ describe AASM::Localizer, "deprecated style" do
end end
end end
context 'aasm_human_event_name' do context 'aasm.human_event_name' do
it 'should return translated event name' do it 'should return translated event name' do
expect(LocalizerTestModel.aasm_human_event_name(:close)).to eq("Let's close it!") expect(LocalizerTestModel.aasm.human_event_name(:close)).to eq("Let's close it!")
end end
it 'should return humanized event name' do it 'should return humanized event name' do
expect(LocalizerTestModel.aasm_human_event_name(:open)).to eq("Open") expect(LocalizerTestModel.aasm.human_event_name(:open)).to eq("Open")
end end
end end
end end