Skip to content

Commit

Permalink
make set_state protected again. it's not accessible on the object anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Fuchs committed Nov 11, 2011
1 parent 2039dd0 commit c077f2d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/simple_states/event.rb
Expand Up @@ -38,15 +38,6 @@ def merge(other, append = true)
end
end

def set_state(object)
if state = target_state(object)
object.past_states << object.state if object.state
object.state = state.to_sym
object.send(:"#{state}_at=", Time.now) if object.respond_to?(:"#{state}_at=") && object.respond_to?(:"#{state}_at") && object.send(:"#{state}_at").nil?
object.save! if @saving
end
end

protected

def skip?(object, args)
Expand All @@ -64,6 +55,15 @@ def run_callbacks(object, type, args)
send_methods(object, options.send(type), args)
end

def set_state(object)
if state = target_state(object)
object.past_states << object.state if object.state
object.state = state.to_sym
object.send(:"#{state}_at=", Time.now) if object.respond_to?(:"#{state}_at=") && object.respond_to?(:"#{state}_at") && object.send(:"#{state}_at").nil?
object.save! if @saving
end
end

def target_state(object)
options.to || :"#{name}ed".tap do |state|
raise_unknown_target_state(object) unless object.class.states.include?(state)
Expand Down

0 comments on commit c077f2d

Please sign in to comment.