Skip to content

Commit

Permalink
Merge pull request #198 from acconrad/patch-1
Browse files Browse the repository at this point in the history
Remove redundant to_s calls
  • Loading branch information
alto committed Dec 26, 2014
2 parents 3008566 + 8f17570 commit eeefb87
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/aasm/base.rb
Expand Up @@ -56,12 +56,12 @@ def initial_state(new_initial_state=nil)
def state(name, options={})
@state_machine.add_state(name, @klass, options)

@klass.send(:define_method, "#{name.to_s}?") do
@klass.send(:define_method, "#{name}?") do
aasm.current_state == name
end

unless @klass.const_defined?("STATE_#{name.to_s.upcase}")
@klass.const_set("STATE_#{name.to_s.upcase}", name)
unless @klass.const_defined?("STATE_#{name.upcase}")
@klass.const_set("STATE_#{name.upcase}", name)
end
end

Expand All @@ -72,16 +72,16 @@ def event(name, options={}, &block)
# an addition over standard aasm so that, before firing an event, you can ask
# may_event? and get back a boolean that tells you whether the guard method
# on the transition will let this happen.
@klass.send(:define_method, "may_#{name.to_s}?") do |*args|
@klass.send(:define_method, "may_#{name}?") do |*args|
aasm.may_fire_event?(name, *args)
end

@klass.send(:define_method, "#{name.to_s}!") do |*args, &block|
aasm.current_event = "#{name.to_s}!".to_sym
@klass.send(:define_method, "#{name}!") do |*args, &block|
aasm.current_event = "#{name}!".to_sym
aasm_fire_event(name, {:persist => true}, *args, &block)
end

@klass.send(:define_method, "#{name.to_s}") do |*args, &block|
@klass.send(:define_method, "#{name}") do |*args, &block|
aasm.current_event = name.to_sym
aasm_fire_event(name, {:persist => false}, *args, &block)
end
Expand Down

0 comments on commit eeefb87

Please sign in to comment.