lib/acfs/model/attributes.rb in acfs-0.32.1.1.b274 vs lib/acfs/model/attributes.rb in acfs-0.32.1.1.b275
- old
+ new
@@ -96,9 +96,19 @@
# @see #write_attribute Delegates attribute values to `#write_attribute`.
#
def write_attributes(attributes, opts = {})
return false unless attributes.respond_to? :each
+ if opts.fetch(:unknown,:ignore) == :raise
+ if (attributes.keys.map(&:to_s) - self.class.attributes.keys).any?
+ raise ArgumentError.new "Unknown attributes: #{(attributes.keys - self.class.attributes.keys).map(&:inspect).join(', ')}"
+ end
+ end
+
+ attributes = attributes.select do |k, v|
+ self.class.attributes.keys.include? k.to_s
+ end
+
procs = {}
attributes.each do |key, _|
if attributes[key].is_a? Proc
procs[key] = attributes[key]