Module: ActiveFedora::RegisteredAttributes::ClassMethods

Defined in:
lib/active_fedora/registered_attributes.rb

Instance Method Summary collapse

Instance Method Details

#attribute(attribute_name, options = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/active_fedora/registered_attributes.rb', line 45

def attribute(attribute_name, options ={})
  self.attribute_registry.register(attribute_name, options) do |attribute|

    attribute.with_validation_options do |name, opts|
      validates(name, opts)
    end

    attribute.with_accession_options do |name, opts|
      attr_accessor name
    end

    attribute.with_delegation_options do |name, opts|
      has_attributes(name, opts)
    end

    attribute.wrap_writer_method(self)
    attribute.wrap_reader_method(self)
  end
end

#attribute_registryObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/active_fedora/registered_attributes.rb', line 22

def attribute_registry
  @attribute_registry ||=
  begin
    if superclass.respond_to?(:attribute_registry)
      superclass.attribute_registry.copy_to(self)
    else
      AttributeRegistry.new(self)
    end
  end
end

#displayable_attributesObject



41
42
43
# File 'lib/active_fedora/registered_attributes.rb', line 41

def displayable_attributes
  attribute_registry.displayable_attributes
end

#editable_attributesObject



37
38
39
# File 'lib/active_fedora/registered_attributes.rb', line 37

def editable_attributes
  attribute_registry.editable_attributes
end

#registered_attribute_namesObject



33
34
35
# File 'lib/active_fedora/registered_attributes.rb', line 33

def registered_attribute_names
  attribute_registry.keys.collect(&:to_s)
end