Class: Aequitas::Rule::PrimitiveType
- Inherits:
-
Aequitas::Rule
- Object
- Aequitas::Rule
- Aequitas::Rule::PrimitiveType
- Defined in:
- lib/aequitas/rule/primitive_type.rb,
lib/aequitas/rule/primitive_type/virtus.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Virtus
Instance Attribute Summary collapse
-
#primitive ⇒ Object
readonly
Returns the value of attribute primitive.
Attributes inherited from Aequitas::Rule
#attribute_name, #custom_message, #guard, #skip_condition
Attributes included from ValueObject
Instance Method Summary collapse
-
#initialize(attribute_name, options = {}) ⇒ PrimitiveType
constructor
A new instance of PrimitiveType.
- #primitive?(value) ⇒ Boolean
- #valid?(resource) ⇒ Boolean
- #violation_data(resource) ⇒ Object
- #violation_type(resource) ⇒ Object
Methods inherited from Aequitas::Rule
#attribute_value, #execute?, rules_for, #skip?, #validate, #violation_info, #violation_values
Methods included from ValueObject
Constructor Details
#initialize(attribute_name, options = {}) ⇒ PrimitiveType
Returns a new instance of PrimitiveType.
11 12 13 14 15 |
# File 'lib/aequitas/rule/primitive_type.rb', line 11 def initialize(attribute_name, = {}) super @primitive = .fetch(:primitive) end |
Instance Attribute Details
#primitive ⇒ Object (readonly)
Returns the value of attribute primitive.
9 10 11 |
# File 'lib/aequitas/rule/primitive_type.rb', line 9 def primitive @primitive end |
Instance Method Details
#primitive?(value) ⇒ Boolean
23 24 25 |
# File 'lib/aequitas/rule/primitive_type.rb', line 23 def primitive?(value) value.is_a?(primitive) end |
#valid?(resource) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/aequitas/rule/primitive_type.rb', line 17 def valid?(resource) value = attribute_value(resource) skip?(value) || primitive?(value) end |
#violation_data(resource) ⇒ Object
31 32 33 |
# File 'lib/aequitas/rule/primitive_type.rb', line 31 def violation_data(resource) [ [ :primitive, primitive ] ] end |
#violation_type(resource) ⇒ Object
27 28 29 |
# File 'lib/aequitas/rule/primitive_type.rb', line 27 def violation_type(resource) :primitive end |