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.1.2 lib/active_fedora/with_metadata.rb
active-fedora-11.1.1 lib/active_fedora/with_metadata.rb
active-fedora-11.1.0 lib/active_fedora/with_metadata.rb
active-fedora-10.3.0 lib/active_fedora/with_metadata.rb
active-fedora-11.0.1 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0 lib/active_fedora/with_metadata.rb
active-fedora-10.3.0.rc2 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc7 lib/active_fedora/with_metadata.rb
active-fedora-10.3.0.rc1 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc6 lib/active_fedora/with_metadata.rb
active-fedora-10.2.1 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc5 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc4 lib/active_fedora/with_metadata.rb
active-fedora-10.2.0 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc3 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc2 lib/active_fedora/with_metadata.rb
active-fedora-11.0.0.rc1 lib/active_fedora/with_metadata.rb
active-fedora-10.1.0 lib/active_fedora/with_metadata.rb
active-fedora-10.1.0.rc1 lib/active_fedora/with_metadata.rb
active-fedora-10.0.0 lib/active_fedora/with_metadata.rb