Class: VanillaValidator::Rules::OtherRule
- Inherits:
-
Object
- Object
- VanillaValidator::Rules::OtherRule
- Defined in:
- lib/vanilla_validator/rules/other_rule.rb
Constant Summary collapse
- DEFAULT_RULE_NAME =
'eq'.freeze
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, term_array) ⇒ OtherRule
constructor
A new instance of OtherRule.
Constructor Details
#initialize(input, term_array) ⇒ OtherRule
Returns a new instance of OtherRule.
8 9 10 11 12 13 14 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 8 def initialize(input, term_array) self.attribute = term_array[0] self.name = term_array.length == 2 ? DEFAULT_RULE_NAME : term_array[1] self.parameters = self.normalize(term_array[name == DEFAULT_RULE_NAME ? 1..-1 : 2..-1]) self.value = ValueExtractor.get(input, attribute) self.klass = self.initialize_rule(name, value, parameters) end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
4 5 6 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 4 def attribute @attribute end |
#klass ⇒ Object
Returns the value of attribute klass.
4 5 6 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 4 def klass @klass end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 4 def name @name end |
#parameters ⇒ Object
Returns the value of attribute parameters.
4 5 6 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 4 def parameters @parameters end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 4 def value @value end |
Class Method Details
.call(input, term_array) ⇒ Object
16 17 18 |
# File 'lib/vanilla_validator/rules/other_rule.rb', line 16 def self.call(input, term_array) self.new(input, term_array) end |