Module: ActiveFedora::Attributes
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern, Deprecation
- Includes:
- ActiveModel::Dirty, ActiveModel::ForbiddenAttributesProtection
- Included in:
- Base
- Defined in:
- lib/active_fedora.rb,
lib/active_fedora/attributes.rb,
lib/active_fedora/attributes/node_config.rb,
lib/active_fedora/attributes/primary_key.rb,
lib/active_fedora/attributes/serializers.rb,
lib/active_fedora/attributes/property_builder.rb
Defined Under Namespace
Modules: ClassMethods, PrimaryKey, Serializers
Classes: NodeConfig, PropertyBuilder
Instance Method Summary
collapse
Instance Method Details
#[](key) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_fedora/attributes.rb', line 30
def [](key)
if assoc = association(key.to_sym)
assoc.reader
elsif self.class.properties.key?(key.to_s) || self.class.attributes_with_defaults.include?(key.to_s)
send(key)
else
array_reader(key)
end
end
|
#[]=(key, value) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/active_fedora/attributes.rb', line 43
def []=(key, value)
raise ReadOnlyRecord if readonly?
if assoc = association(key.to_sym)
assoc.replace(value)
elsif self.class.properties.key?(key.to_s)
send(key.to_s + "=", value)
else
array_setter(key, value)
end
end
|
#attribute_names ⇒ Object
22
23
24
|
# File 'lib/active_fedora/attributes.rb', line 22
def attribute_names
self.class.attribute_names
end
|
#attributes ⇒ Object
26
27
28
|
# File 'lib/active_fedora/attributes.rb', line 26
def attributes
attribute_names.each_with_object("id" => id) { |key, hash| hash[key] = self[key] }
end
|
#local_attributes ⇒ Object
67
68
69
|
# File 'lib/active_fedora/attributes.rb', line 67
def local_attributes
self.class.local_attributes
end
|
#mark_as_changed(field) ⇒ Object
63
64
65
|
# File 'lib/active_fedora/attributes.rb', line 63
def mark_as_changed(field)
send("#{field}_will_change!")
end
|
#value_has_changed?(field, new_value) ⇒ Boolean
value different from the new_value.
59
60
61
|
# File 'lib/active_fedora/attributes.rb', line 59
def value_has_changed?(field, new_value)
new_value != array_reader(field)
end
|