Sha256: 2c048c74ae3e1e3fd3d1d553782dca53c531f253abf3dae2c2efedeccda66bd1
Contents?: true
Size: 1.14 KB
Versions: 38
Compression:
Stored size: 1.14 KB
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(to_hash) end def merge(new_hash) self.class.new(to_hash.merge(new_hash)) end def to_hash @hash.deep_dup end # this enables a cleaner API for solr integration class IndexObject attr_accessor :data_type, :behaviors, :term attr_reader :key def initialize(name, behaviors: [], &_block) @behaviors = behaviors @data_type = :string @key = name yield self if block_given? end def as(*args) @term = args.last.is_a?(Hash) ? args.pop : {} @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
38 entries across 38 versions & 1 rubygems