lib/maglev/active_model/when_change.rb
# will add a validation message if the from/to states match
will add a validation message if the from/to states match
will add a validation message if the from / to states match
def invalidate(msg = nil, &block)
          field = @field
          add_callback(:validate) do |from, to|
            if block
              msg = instance_exec(from, to, &block)
              if msg
                self.errors[field] << msg
              end
            else
              self.errors[field] << msg || 'is an invalid'
            end
          end
        end
def invalidate ( msg = nil , & block ) field = @field add_callback ( :validate ) do | from , to | if block msg = instance_exec ( from , to , & block ) if msg self . errors [ field ] << msg end else self . errors [ field ] << msg || 'is an invalid' end end end
will add a validation message if the from/to states match
will add a validation message if the from / to states match
msg
<not_specific>
block
<not_specific>