Sha256: d5fe3762643febf86f2b99abfdeaec87fd426d48aeb657de935d4986c10631ac

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

module Kithe
  class IndexableSettings
    attr_accessor :solr_url, :writer_class_name, :writer_settings,
                  :model_name_solr_field, :solr_id_value_attribute, :disable_callbacks
    def initialize(solr_url:, writer_class_name:, writer_settings:,
                   model_name_solr_field:, solr_id_value_attribute:, disable_callbacks: false)
      @solr_url = solr_url
      @writer_class_name = writer_class_name
      @writer_settings = writer_settings
      @model_name_solr_field = model_name_solr_field
      @solr_id_value_attribute = solr_id_value_attribute || 'id'
    end

    # Use configured solr_url, and merge together with configured
    # writer_settings
    def writer_settings
      if solr_url
        { "solr.url" => solr_url }.merge(@writer_settings)
      else
        @writer_settings
      end
    end

    # Turn writer_class_name into an actual Class object.
    def writer_class
      writer_class_name.constantize
    end

    # Instantiate a new writer based on `writer_class_name` and `writer_settings`
    def writer_instance!(additional_settings = {})
      writer_class.new(writer_settings.merge(additional_settings))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kithe-2.2.0 lib/kithe/indexable_settings.rb
kithe-2.1.0 lib/kithe/indexable_settings.rb
kithe-2.0.3 lib/kithe/indexable_settings.rb
kithe-2.0.2 lib/kithe/indexable_settings.rb