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:
parent
7f3c08199b
commit
ef70ac53d9
4 changed files with 21 additions and 8 deletions
|
@ -1,5 +1,9 @@
|
|||
# CHANGELOG
|
||||
|
||||
## 4.1.0 (not yet released)
|
||||
|
||||
* `aasm_human_event_name` is deprecated, use `aasm.human_event_name` instead
|
||||
|
||||
## 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)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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:
|
||||
base.extend AASM::ClassMethods
|
||||
|
||||
|
@ -26,9 +29,10 @@ module AASM
|
|||
@aasm
|
||||
end
|
||||
|
||||
# aasm.event(:event_name).human?
|
||||
# deprecated, remove in version 4.1
|
||||
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 # ClassMethods
|
||||
|
||||
|
|
|
@ -85,6 +85,11 @@ module AASM
|
|||
@state_machine.events.values
|
||||
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
|
||||
states.map { |state| state.for_select }
|
||||
end
|
||||
|
|
|
@ -67,13 +67,13 @@ describe AASM::Localizer, "new style" do
|
|||
end
|
||||
end
|
||||
|
||||
context 'aasm_human_event_name' do
|
||||
context 'aasm.human_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
|
||||
|
||||
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
|
||||
|
@ -102,13 +102,13 @@ describe AASM::Localizer, "deprecated style" do
|
|||
end
|
||||
end
|
||||
|
||||
context 'aasm_human_event_name' do
|
||||
context 'aasm.human_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
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue