Sha256: fd751f822aadcdc502915074bbde90a4e734dc43df7a373438c0fdfdf282523a

Contents?: true

Size: 614 Bytes

Versions: 9

Compression:

Stored size: 614 Bytes

Contents

module Flare
  class IndexBuilder
    attr_reader :fields

    def initialize(&block)
      @fields = []
      @attributes = {}
      self.instance_eval(&block) if block_given?
    end

    def index
      { :fields => @fields, :attributes => @attributes }
    end

    protected
      def field(*args)
        field, options = args.first, args.extract_options!
        @fields << {
          :source => field, 
          :name => options[:as] || field, 
          :boost => options[:boost] || nil
          }
      end
      
      def attribute(name, value)
        @attributes[name] = value
      end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
flare-1.7.0 lib/flare/index_builder.rb
flare-1.6.1 lib/flare/index_builder.rb
flare-1.4.4 lib/flare/index_builder.rb
flare-1.4.3 lib/flare/index_builder.rb
flare-1.4.2 lib/flare/index_builder.rb
flare-1.4.1 lib/flare/index_builder.rb
flare-1.4.0 lib/flare/index_builder.rb
flare-1.3.0 lib/flare/index_builder.rb
flare-1.2.0 lib/flare/index_builder.rb