lib/acts_as_state_machine.rb
# 11/10/08 Modified what gets passed to the validation so it includes the :if proc normally used in validation
11/10/08 Modified what gets passed to the validation so it includes the :if proc normally used in validation
11 / 10 / 08 Modified what gets passed to the validation so it includes the : if proc normally used in validation
def method_missing(method, *args)
        proc = args.last[:if] unless args.nil? || args.last.class != Hash
        if @state.nil?
          configuration = args.extract_options!
          configuration.update({:if => Proc.new{|u| !u.current_state.nil? && u.current_state == @state && ( proc.nil? || proc.call(u) )}})
          args.push(configuration)
          @klass.send(method, *args)
        else
          configuration = args.extract_options!
          configuration.update({:if => Proc.new{|u| !u.current_state.nil? && !u.current_transition.nil?  && u.current_state == @state && u.current_transition == @transition  && ( proc.nil? || proc.call(u) )}})
          args.push(configuration)
          @klass.send(method, *args)
        end
      end
def method_missing ( method , * args ) proc = args . last [ :if ] unless args . nil? || args . last . class != Hash if @state . nil? configuration = args . extract_options! configuration . update ( { :if => Proc . new { | u | ! u . current_state . nil? && u . current_state == @state && ( proc . nil? || proc . call ( u ) ) } } ) args . push ( configuration ) @klass . send ( method , * args ) else configuration = args . extract_options! configuration . update ( { :if => Proc . new { | u | ! u . current_state . nil? && ! u . current_transition . nil? && u . current_state == @state && u . current_transition == @transition && ( proc . nil? || proc . call ( u ) ) } } ) args . push ( configuration ) @klass . send ( method , * args ) end end
11/10/08 Modified what gets passed to the validation so it includes the :if proc normally used in validation
11 / 10 / 08 Modified what gets passed to the validation so it includes the : if proc normally used in validation
method
<not_specific>
args
<not_specific>