Sha256: 434be25699c198c0191134cd78cd123610a9ac257a78cd10f1919d52efc8326f

Contents?: true

Size: 966 Bytes

Versions: 43

Compression:

Stored size: 966 Bytes

Contents

module ActiveFedora
  module WithMetadata
    extend ActiveSupport::Concern
    extend ActiveSupport::Autoload

    autoload :MetadataNode
    autoload :SweetJPLTerms
    autoload :DefaultStrategy
    autoload :DefaultSchema
    autoload :DefaultMetadataClassFactory

    included do
      class_attribute :metadata_class_factory
      self.metadata_class_factory = DefaultMetadataClassFactory
    end

    def metadata_node
      @metadata_node ||= self.class.metadata_schema.new(self)
    end

    def create_or_update(*)
      return unless super && !new_record?
      metadata_node.metadata_uri = described_by # TODO: only necessary if the URI was < > before
      metadata_node.save # TODO if changed?
    end

    module ClassMethods
      def metadata(&block)
        @metadata_schema = metadata_class_factory.build(self, &block)
      end

      def metadata_schema
        @metadata_schema ||= metadata_class_factory.build(self)
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
active-fedora-11.5.6 lib/active_fedora/with_metadata.rb
active-fedora-11.2.1 lib/active_fedora/with_metadata.rb
active-fedora-12.0.3 lib/active_fedora/with_metadata.rb
active-fedora-11.5.5 lib/active_fedora/with_metadata.rb
active-fedora-11.5.4 lib/active_fedora/with_metadata.rb
active-fedora-11.5.3 lib/active_fedora/with_metadata.rb
active-fedora-12.0.2 lib/active_fedora/with_metadata.rb
active-fedora-12.0.1 lib/active_fedora/with_metadata.rb
active-fedora-11.5.2 lib/active_fedora/with_metadata.rb
active-fedora-12.0.0 lib/active_fedora/with_metadata.rb
active-fedora-11.5.0 lib/active_fedora/with_metadata.rb
active-fedora-11.4.1 lib/active_fedora/with_metadata.rb
active-fedora-11.4.0 lib/active_fedora/with_metadata.rb
active-fedora-11.3.1 lib/active_fedora/with_metadata.rb
active-fedora-11.3.0 lib/active_fedora/with_metadata.rb
active-fedora-11.2.0 lib/active_fedora/with_metadata.rb
active-fedora-11.1.6 lib/active_fedora/with_metadata.rb
active-fedora-11.1.5 lib/active_fedora/with_metadata.rb
active-fedora-11.1.4 lib/active_fedora/with_metadata.rb
active-fedora-11.1.3 lib/active_fedora/with_metadata.rb