Class: Bound::BoundValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/bound.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bound, target, overwrite) ⇒ BoundValidator



37
38
39
40
41
# File 'lib/bound.rb', line 37

def initialize(bound, target, overwrite)
  @bound = bound
  @target = target || {}
  @overwrite = overwrite || {}
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



35
36
37
# File 'lib/bound.rb', line 35

def attributes
  @attributes
end

#nested_array_attributesObject

Returns the value of attribute nested_array_attributes.



35
36
37
# File 'lib/bound.rb', line 35

def nested_array_attributes
  @nested_array_attributes
end

#optional_attributesObject

Returns the value of attribute optional_attributes.



35
36
37
# File 'lib/bound.rb', line 35

def optional_attributes
  @optional_attributes
end

Instance Method Details

#validate!Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/bound.rb', line 43

def validate!
  ensure_all_given_attributes_are_known!
  attributes.each do |attribute|
    ensure_present! attribute
  end
  nested_array_attributes.each do |nested_array_attribute|
    ensure_array! nested_array_attribute
  end
  ensure_all_attributes_are_callable!
end