module ActiveFedora::Attributes
Public Instance Methods
[](key)
click to toggle source
# File lib/active_fedora/attributes.rb, line 46 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
[]=(key, value)
click to toggle source
# File lib/active_fedora/attributes.rb, line 58 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
attribute_names()
click to toggle source
# File lib/active_fedora/attributes.rb, line 38 def attribute_names self.class.attribute_names end
attributes()
click to toggle source
# File lib/active_fedora/attributes.rb, line 42 def attributes attribute_names.each_with_object("id" => id) { |key, hash| hash[key] = self[key] } end
clear_changed_attributes()
click to toggle source
@deprecated use changes_applied instead
# File lib/active_fedora/attributes.rb, line 14 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
clear_changed_attributes_or_changes_applied()
click to toggle source
Call the deprecated method
@deprecated use changes_applied instead @api private
# File lib/active_fedora/attributes.rb, line 25 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
local_attributes()
click to toggle source
# File lib/active_fedora/attributes.rb, line 71 def local_attributes self.class.local_attributes end