Sha256: 55451fdb4c177bc6c81c69f784e1d054f5d7385e9acf72ec80c1325098671cc7

Contents?: true

Size: 852 Bytes

Versions: 7

Compression:

Stored size: 852 Bytes

Contents

module AgnosticBackend
  class Index

    attr_reader :options

    def initialize(indexable_klass, primary: true, **options)
      @indexable_klass = indexable_klass
      @primary = primary
      @options = options
      parse_options
    end

    def primary?
      @primary
    end

    def name
      @indexable_klass.index_name
    end

    def schema
      @indexable_klass.schema
    end

    def indexer
      raise NotImplementedError
    end

    def configure(new_schema = nil)
      raise NotImplementedError
    end

    def parse_options
      raise NotImplementedError
    end

    def parse_option(option_name, optional: false, default: nil)
      if options.has_key?(option_name)
        options[option_name]
      elsif optional
        default
      else
        raise "#{option_name} must be specified"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
agnostic_backend-1.0.4 lib/agnostic_backend/index.rb
agnostic_backend-1.0.3 lib/agnostic_backend/index.rb
agnostic_backend-1.0.2 lib/agnostic_backend/index.rb
agnostic_backend-1.0.1 lib/agnostic_backend/index.rb
agnostic_backend-1.0.0 lib/agnostic_backend/index.rb
agnostic_backend-0.9.9 lib/agnostic_backend/index.rb
agnostic_backend-0.9.8 lib/agnostic_backend/index.rb