Module: ActiveFedora::Attributes::ClassMethods
- Defined in:
- lib/active_fedora/attributes.rb
Instance Method Summary collapse
-
#association_attributes ⇒ Object
Attributes that represent associations to other repository objects.
- #attribute_names ⇒ Object
-
#attributes_with_defaults ⇒ Object
From ActiveFedora::FedoraAttributes.
- #delegated_attributes ⇒ Object
- #delegated_attributes=(val) ⇒ Object
-
#local_attributes ⇒ Object
Attributes that are asserted about this RdfSource (not on a datastream).
-
#multiple?(field) ⇒ Boolean
Reveal if the attribute is multivalued.
- #property(name, properties = {}, &block) ⇒ Object
-
#system_attributes ⇒ Object
Attributes that are required by ActiveFedora and Fedora.
-
#unique?(field) ⇒ Boolean
Reveal if the attribute has been declared unique.
Instance Method Details
#association_attributes ⇒ Object
Attributes that represent associations to other repository objects
105 106 107 |
# File 'lib/active_fedora/attributes.rb', line 105 def association_attributes outgoing_reflections.values.map { |reflection| reflection.foreign_key.to_s } end |
#attribute_names ⇒ Object
85 86 87 |
# File 'lib/active_fedora/attributes.rb', line 85 def attribute_names @attribute_names ||= delegated_attributes.keys + association_attributes - system_attributes end |
#attributes_with_defaults ⇒ Object
From ActiveFedora::FedoraAttributes
100 101 102 |
# File 'lib/active_fedora/attributes.rb', line 100 def attributes_with_defaults ['type', 'rdf_label'] end |
#delegated_attributes ⇒ Object
109 110 111 112 113 114 |
# File 'lib/active_fedora/attributes.rb', line 109 def delegated_attributes @delegated_attributes ||= {}.with_indifferent_access return @delegated_attributes unless superclass.respond_to?(:delegated_attributes) && value = superclass.delegated_attributes @delegated_attributes = value.dup if @delegated_attributes.empty? @delegated_attributes end |
#delegated_attributes=(val) ⇒ Object
116 117 118 |
# File 'lib/active_fedora/attributes.rb', line 116 def delegated_attributes=(val) @delegated_attributes = val end |
#local_attributes ⇒ Object
Attributes that are asserted about this RdfSource (not on a datastream)
90 91 92 |
# File 'lib/active_fedora/attributes.rb', line 90 def local_attributes association_attributes + properties.keys - system_attributes end |
#multiple?(field) ⇒ Boolean
Reveal if the attribute is multivalued
130 131 132 133 |
# File 'lib/active_fedora/attributes.rb', line 130 def multiple?(field) raise UnknownAttributeError.new(nil, field, self) unless delegated_attributes.key?(field) delegated_attributes[field].multiple end |
#property(name, properties = {}, &block) ⇒ Object
135 136 137 138 |
# File 'lib/active_fedora/attributes.rb', line 135 def property(name, properties = {}, &block) raise ArgumentError, "You must provide a `:predicate' option to property" unless properties.key?(:predicate) define_active_triple_accessor(name, properties, &block) end |
#system_attributes ⇒ Object
Attributes that are required by ActiveFedora and Fedora
95 96 97 |
# File 'lib/active_fedora/attributes.rb', line 95 def system_attributes ['has_model', 'create_date', 'modified_date'] end |
#unique?(field) ⇒ Boolean
Reveal if the attribute has been declared unique
123 124 125 |
# File 'lib/active_fedora/attributes.rb', line 123 def unique?(field) !multiple?(field) end |