mirror of
				https://github.com/aasm/aasm
				synced 2023-03-27 23:22:41 -04:00 
			
		
		
		
	deprecated AASM#human_state and AASM.human_event_name, which will be removed in AASM version 3
This commit is contained in:
		
							parent
							
								
									1187512243
								
							
						
					
					
						commit
						ae98094ee8
					
				
					 4 changed files with 27 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -10,3 +10,6 @@ require File.join(File.dirname(__FILE__), 'aasm', 'supporting_classes', 'localiz
 | 
			
		|||
require File.join(File.dirname(__FILE__), 'aasm', 'state_machine')
 | 
			
		||||
require File.join(File.dirname(__FILE__), 'aasm', 'persistence')
 | 
			
		||||
require File.join(File.dirname(__FILE__), 'aasm', 'aasm')
 | 
			
		||||
 | 
			
		||||
# load the deprecated methods and modules
 | 
			
		||||
Dir[File.join(File.dirname(__FILE__), 'aasm', 'deprecated', '*.rb')].sort.each { |f| require File.expand_path(f) }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ module AASM
 | 
			
		|||
      aasm.states_for_select
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def human_event_name(event)
 | 
			
		||||
    def aasm_human_event_name(event)
 | 
			
		||||
      AASM::SupportingClasses::Localizer.new.human_event_name(self, event)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -85,6 +85,7 @@ module AASM
 | 
			
		|||
    state_name
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # private?
 | 
			
		||||
  def aasm_events_for_current_state
 | 
			
		||||
    aasm_events_for_state(aasm_current_state)
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +101,7 @@ module AASM
 | 
			
		|||
    events.map {|event| event.name}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def human_state
 | 
			
		||||
  def aasm_human_state
 | 
			
		||||
    AASM::SupportingClasses::Localizer.new.human_state(self)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								lib/aasm/deprecated/aasm.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lib/aasm/deprecated/aasm.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
module AASM
 | 
			
		||||
 | 
			
		||||
  module ClassMethods
 | 
			
		||||
    def human_event_name(*args)
 | 
			
		||||
      warn "AASM.human_event_name is deprecated and will be removed in version 3.0.0; please use AASM.aasm_human_event_name instead!"
 | 
			
		||||
      aasm_human_event_name(*args)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def human_state
 | 
			
		||||
    warn "AASM#human_state is deprecated and will be removed in version 3.0.0; please use AASM#aasm_human_state instead!"
 | 
			
		||||
    aasm_human_state
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -29,23 +29,23 @@ describe AASM::SupportingClasses::Localizer do
 | 
			
		|||
  let (:foo_opened) { LocalizerTestModel.new }
 | 
			
		||||
  let (:foo_closed) { LocalizerTestModel.new.tap { |x| x.aasm_state = :closed  } }
 | 
			
		||||
 | 
			
		||||
  context '.human_state' do
 | 
			
		||||
  context 'aasm_human_state' do
 | 
			
		||||
    it 'should return translated state value' do
 | 
			
		||||
       foo_opened.human_state.should == "It's opened now!"
 | 
			
		||||
       foo_opened.aasm_human_state.should == "It's opened now!"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should return humanized value if not localized' do
 | 
			
		||||
      foo_closed.human_state.should == "Closed"
 | 
			
		||||
      foo_closed.aasm_human_state.should == "Closed"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context '.human_event_name' do
 | 
			
		||||
  context 'aasm_human_event_name' do
 | 
			
		||||
    it 'should return translated event name' do
 | 
			
		||||
      LocalizerTestModel.human_event_name(:close).should == "Let's close it!"
 | 
			
		||||
      LocalizerTestModel.aasm_human_event_name(:close).should == "Let's close it!"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'should return humanized event name' do
 | 
			
		||||
      LocalizerTestModel.human_event_name(:open).should == "Open"
 | 
			
		||||
      LocalizerTestModel.aasm_human_event_name(:open).should == "Open"
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue