module ActiveFedora::Attributes
def [](key)
def [](key) if assoc = association(key.to_sym) # This is for id attributes stored in the rdf graph. assoc.reader elsif self.class.properties.key?(key.to_s) || self.class.attributes_with_defaults.include?(key.to_s) # Use the generated method so that single value assetions are single send(key) else raise ArgumentError, "Unknown attribute #{key}" end end
def []=(key, value)
def []=(key, value) raise ReadOnlyRecord if readonly? if assoc = association(key.to_sym) # This is for id attributes stored in the rdf graph. assoc.replace(value) elsif self.class.properties.key?(key.to_s) # The attribute is stored in the RDF graph for this object send(key.to_s + "=", value) else raise ArgumentError, "Unknown attribute #{key}" end end
def attribute_method?(attr_name) # :nodoc:
causes a load of all the datastreams.
the callback methods seem to trigger this, which means just initing an object (after_init)
override activemodel so it doesn't trigger a load of all the attributes.
def attribute_method?(attr_name) # :nodoc: respond_to_without_attributes?(:attributes) && self.class.delegated_attributes.include?(attr_name) end
def attribute_names
def attribute_names self.class.attribute_names end
def attributes
def attributes attribute_names.each_with_object("id" => id) { |key, hash| hash[key] = self[key] } end
def clear_changed_attributes
- use #changes_applied instead
def clear_changed_attributes Deprecation.warn ActiveFedora::Attributes, "#clear_changed_attributes is deprecated, use ActiveModel::Dirty#changes_applied instead." @previously_changed = changes clear_attribute_changes(changes.keys) end
def clear_changed_attributes_or_changes_applied
- Api: - private
Deprecated:
- use #changes_applied instead
def clear_changed_attributes_or_changes_applied return changes_applied if method(:clear_changed_attributes).super_method.nil? || method(:clear_changed_attributes).owner == ActiveFedora::Aggregation::ListSource Deprecation.warn self.class, "after_save callbacks to #clear_changed_attributes are deprecated. " / "These calls will be removed in 14.0.0. If you are running Rails 6.0, " / "it's likely your #clear_changed_attributes implementation is in " / "conflict with new ActiveModel::Dirty behavior." clear_changed_attributes end
def local_attributes
def local_attributes self.class.local_attributes end