Class: Validatable::ValidatesTrueFor

Inherits:
ValidationBase show all
Defined in:
lib/validatable/validations/validates_true_for.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from ValidationBase

#after_validate, #allow_blank, #allow_nil, #attribute, #if, #klass

Instance Method Summary collapse

Methods inherited from ValidationBase

#initialize, #validate

Constructor Details

This class inherits a constructor from Validatable::ValidationBase

Instance Attribute Details

#logicObject

Returns the value of attribute logic.



3
4
5
# File 'lib/validatable/validations/validates_true_for.rb', line 3

def logic
  @logic
end

Instance Method Details

#message(instance) ⇒ Object



9
10
11
# File 'lib/validatable/validations/validates_true_for.rb', line 9

def message(instance)
  super || "is invalid"
end

#valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/validatable/validations/validates_true_for.rb', line 5

def valid?(instance)
  instance.instance_eval(&logic) == true
end