Sha256: 42e967191d47322f57e138bb37ad5d3008e781c1920573353a13dc98c25a1253
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
module ObjectAttorney module AttributeAssignment def assign_attributes(attributes = {}) return if attributes.blank? attributes.each do |name, value| send("#{name}=", value) if allowed_attribute(name) end mark_for_destruction_if_necessary(self, attributes) end protected #################### PROTECTED METHODS DOWN BELOW ###################### def parsing_arguments(attributes, object) if !attributes.is_a?(Hash) && object.blank? object = attributes attributes = nil end attributes = {} if attributes.blank? [attributes, object] end def allowed_attribute(attribute) respond_to?("#{attribute}=") end def attributes_without_destroy(attributes) return nil unless attributes.is_a?(Hash) _attributes = attributes.dup _attributes.delete("_destroy") _attributes.delete(:_destroy) _attributes end def attributes_order_destruction?(attributes) _destroy = attributes["_destroy"] || attributes[:_destroy] ["true", "1", true].include?(_destroy) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
object_attorney-2.6.1 | lib/object_attorney/attribute_assignment.rb |
object_attorney-2.6.0 | lib/object_attorney/attribute_assignment.rb |