Sha256: 15dc6b9c333b444fb3688103262137e271c73b2ba299479d029e02bbb75e0826

Contents?: true

Size: 962 Bytes

Versions: 10

Compression:

Stored size: 962 Bytes

Contents

require 'forwardable'
module ActiveFedora::Indexing
  # This is a description of how properties should map to indexing strategies
  #  e.g. 'creator_name' => <IndexObject behaviors=[:stored_searchable, :facetable]>
  class Map
    extend Forwardable
    def_delegators :@hash, :[], :[]=, :each, :keys

    def initialize(hash = {})
      @hash = hash
    end

    def dup
      self.class.new(@hash.deep_dup)
    end

    # this enables a cleaner API for solr integration
    class IndexObject
      attr_accessor :data_type, :behaviors
      attr_reader :key

      def initialize(name, &block)
        @behaviors = []
        @data_type = :string
        @key = name
        yield self if block_given?
      end

      def as(*args)
        @behaviors = args
      end

      def type(sym)
        @data_type = sym
      end

      def dup
        self.class.new(@key) do |idx|
          idx.behaviors = @behaviors.dup
        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/indexing/map.rb
active-fedora-9.4.3 lib/active_fedora/indexing/map.rb
active-fedora-9.4.2 lib/active_fedora/indexing/map.rb
active-fedora-9.4.1 lib/active_fedora/indexing/map.rb
active-fedora-9.4.0 lib/active_fedora/indexing/map.rb
active-fedora-9.3.0 lib/active_fedora/indexing/map.rb
active-fedora-9.2.1 lib/active_fedora/indexing/map.rb
active-fedora-9.2.0 lib/active_fedora/indexing/map.rb
active-fedora-9.2.0.rc2 lib/active_fedora/indexing/map.rb
active-fedora-9.2.0.rc1 lib/active_fedora/indexing/map.rb