Sha256: e177ff25757a7f431e8edd6464d4194f67ff29ce2734a5f4aab4bea64e5dc5e2
Contents?: true
Size: 1.14 KB
Versions: 13
Compression:
Stored size: 1.14 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.symbolize_keys, 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.symbolize_keys end def attributes_order_destruction?(attributes) _destroy = attributes["_destroy"] || attributes[:_destroy] ["true", "1", true].include?(_destroy) end end end
Version data entries
13 entries across 13 versions & 1 rubygems