Sha256: 70894daf3bb874820d67d1de2cabca7a927cee2f84d9a4e756af568078191dde

Contents?: true

Size: 520 Bytes

Versions: 1

Compression:

Stored size: 520 Bytes

Contents

module Ddr
  module Models
    class Index

      Field = Struct.new(:name, :index_as, :method)

      def fields
        @fields ||= {}
      end

      def field(key, *index_as)
        raise "Field :#{key} already indexed." if fields.include?(key)
        fields[key] = Field.new.tap do |f|
          f.name = ActiveFedora::SolrService.solr_name(key, *index_as)
          f.index_as = index_as
          yield f if block_given?
        end
      end

      def [](key)
        fields[key]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ddr-models-1.8.1 lib/ddr/models/#index.rb#