Method: Attributor::Hash.add_requirement
- Defined in:
- lib/attributor/types/hash.rb
.add_requirement(req) ⇒ Object
161 162 163 164 165 166 167 168 169 |
# File 'lib/attributor/types/hash.rb', line 161 def self.add_requirement(req) @requirements << req return unless req.attr_names non_existing = req.attr_names - attributes.keys unless non_existing.empty? raise "Invalid attribute name(s) found (#{non_existing.join(', ')}) when defining a requirement of type #{req.type} for #{Attributor.type_name(self)} ." \ "The only existing attributes are #{attributes.keys}" end end |