Sha256: 348f52f3a1c08753132b0276516a189ec53a76d5b2c7a2aebaedeee607a190a3

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

# encoding: UTF-8

class Spontaneous::Site
  module Search
    extend Spontaneous::Concern

    module ClassMethods
      def index(name, &definition)
        instance.index(name, &definition)
      end

      def indexes
        instance.indexes
      end

      def indexer(revision)
        indexer = S::Search::CompoundIndexer.new(revision, indexes.values)
        begin
          yield(indexer)
        ensure
          indexer.close
        end
      end
    end # ClassMethods

    def indexes
      @indexes ||= {}
    end

    def [](name)
      indexes[name.to_sym]
    end

    def []=(name, index)
      indexes[name.to_sym] = index
    end

    def index(name, &definition)
      index = S::Search::Index.new(name, &definition)
      self[name] = index
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spontaneous-0.2.0.beta4 lib/spontaneous/site/search.rb
spontaneous-0.2.0.beta3 lib/spontaneous/site/search.rb
spontaneous-0.2.0.beta2 lib/spontaneous/site/search.rb
spontaneous-0.2.0.beta1 lib/spontaneous/site/search.rb