Class: StrongerParameters::AndConstraint

Inherits:
Constraint
  • Object
show all
Defined in:
lib/stronger_parameters/constraint.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Constraint

#|

Constructor Details

#initialize(*constraints) ⇒ AndConstraint

Returns a new instance of AndConstraint.



58
59
60
# File 'lib/stronger_parameters/constraint.rb', line 58

def initialize(*constraints)
  @constraints = constraints
end

Instance Attribute Details

#constraintsObject (readonly)

Returns the value of attribute constraints.



56
57
58
# File 'lib/stronger_parameters/constraint.rb', line 56

def constraints
  @constraints
end

Instance Method Details

#&(other) ⇒ Object



70
71
72
73
# File 'lib/stronger_parameters/constraint.rb', line 70

def &(other)
  constraints << other
  self
end

#==(other) ⇒ Object



75
76
77
# File 'lib/stronger_parameters/constraint.rb', line 75

def ==(other)
  super && constraints == other.constraints
end

#value(v) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/stronger_parameters/constraint.rb', line 62

def value(v)
  constraints.each do |c|
    v = c.value(v)
    return v if v.is_a?(InvalidValue)
  end
  v
end