Class: StrongerParameters::AndConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- StrongerParameters::AndConstraint
- Defined in:
- lib/stronger_parameters/constraints.rb
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(*constraints) ⇒ AndConstraint
constructor
A new instance of AndConstraint.
- #value(v) ⇒ Object
Methods inherited from Constraint
Constructor Details
#initialize(*constraints) ⇒ AndConstraint
Returns a new instance of AndConstraint.
57 58 59 |
# File 'lib/stronger_parameters/constraints.rb', line 57 def initialize(*constraints) @constraints = constraints end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
55 56 57 |
# File 'lib/stronger_parameters/constraints.rb', line 55 def constraints @constraints end |
Instance Method Details
#&(other) ⇒ Object
69 70 71 72 |
# File 'lib/stronger_parameters/constraints.rb', line 69 def &(other) constraints << other self end |
#==(other) ⇒ Object
74 75 76 |
# File 'lib/stronger_parameters/constraints.rb', line 74 def ==(other) super && constraints == other.constraints end |
#value(v) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/stronger_parameters/constraints.rb', line 61 def value(v) constraints.each do |c| v = c.value(v) return v if v.is_a?(InvalidValue) end v end |