Sha256: 8793d60f20fea014a9e95eb6ae2c3184a5b77b1399357667e5c12c47dc82013c

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module ActiveFedora
  ##
  # Implement the .apply_schema method from ActiveTriples to allow for
  # externally defined schemas to be put on an AF::Base object.
  module Schema
    extend ActiveSupport::Concern

    module ClassMethods
      # Applies a schema to an ActiveFedora::Base.
      # @note The default application strategy adds no indexing hints. You may
      #   want to implement a different strategy if you want to set values on the
      #   property reflection.
      # @param schema [ActiveTriples::Schema] The schema to apply.
      # @param strategy [#apply] The strategy to use for applying the schema.
      # @example Apply a schema and index everything as symbol.
      #   apply_schema MySchema, ActiveFedora::SchemaIndexingStrategy.new(
      #     ActiveFedora::GlobalIndexer.new(:symbol)
      #   )
      def apply_schema(schema, strategy=ActiveFedora::SchemaIndexingStrategy.new)
        schema.properties.each do |property|
          strategy.apply(self, property)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active-fedora-9.5.0 lib/active_fedora/schema.rb
active-fedora-9.4.3 lib/active_fedora/schema.rb
active-fedora-9.4.2 lib/active_fedora/schema.rb
active-fedora-9.4.1 lib/active_fedora/schema.rb
active-fedora-9.4.0 lib/active_fedora/schema.rb
active-fedora-9.3.0 lib/active_fedora/schema.rb
active-fedora-9.2.1 lib/active_fedora/schema.rb
active-fedora-9.2.0 lib/active_fedora/schema.rb
active-fedora-9.2.0.rc2 lib/active_fedora/schema.rb
active-fedora-9.2.0.rc1 lib/active_fedora/schema.rb