Class: Aequitas::Rule::PrimitiveType::Virtus

Inherits:
Aequitas::Rule::PrimitiveType show all
Defined in:
lib/aequitas/rule/primitive_type/virtus.rb

Instance Attribute Summary collapse

Attributes inherited from Aequitas::Rule::PrimitiveType

#primitive

Attributes inherited from Aequitas::Rule

#attribute_name, #custom_message, #guard, #skip_condition

Attributes included from ValueObject

#equalizer

Instance Method Summary collapse

Methods inherited from Aequitas::Rule::PrimitiveType

#valid?, #violation_data, #violation_type

Methods inherited from Aequitas::Rule

#attribute_value, #execute?, rules_for, #skip?, #validate, #violation_data, #violation_info, #violation_values

Methods included from ValueObject

#equalize_on

Constructor Details

#initialize(attribute_name, options = {}) ⇒ Virtus

Returns a new instance of Virtus.



12
13
14
15
16
# File 'lib/aequitas/rule/primitive_type/virtus.rb', line 12

def initialize(attribute_name, options = {})
  @attribute = options.fetch(:attribute)

  super(attribute_name, :primitive => attribute.class.primitive)
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



10
11
12
# File 'lib/aequitas/rule/primitive_type/virtus.rb', line 10

def attribute
  @attribute
end

Instance Method Details

#primitive?(value) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/aequitas/rule/primitive_type/virtus.rb', line 18

def primitive?(value)
  attribute.value_coerced?(value)
end