Class: Imaginary::Validators::Option
- Inherits:
-
Object
- Object
- Imaginary::Validators::Option
- Defined in:
- lib/imaginary/validators/option.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #append(result, object) ⇒ Object
-
#initialize(type, key) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(type, key) ⇒ Option
Returns a new instance of Option.
9 10 11 12 13 14 |
# File 'lib/imaginary/validators/option.rb', line 9 def initialize(type, key) raise 'Invalid Validator Option Type' unless %i[and or].include? type self.type = type self.key = key end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/imaginary/validators/option.rb', line 7 def key @key end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/imaginary/validators/option.rb', line 6 def type @type end |
Instance Method Details
#append(result, object) ⇒ Object
16 17 18 19 20 |
# File 'lib/imaginary/validators/option.rb', line 16 def append(result, object) return (result && object.include?(key)) if type == :and result || object.include?(key) end |