Method: Validatable::ValidatesAcceptanceOf#valid?

Defined in:
lib/validatable/validations/validates_acceptance_of.rb

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
# File 'lib/validatable/validations/validates_acceptance_of.rb', line 3

def valid?(instance)
  value = instance.send(self.attribute)
  return true if allow_nil && value.nil?
  return true if allow_blank && (!value or (value.respond_to?(:empty?) and value.empty?))
  %w(1 true t).include?(value)
end