class BuwebContentModels::Configuration

Attributes

elasticsearch_index[RW]
elasticsearch_mappings[RW]
elasticsearch_settings[RW]
elasticsearchable_models[RW]
roz_access_id[RW]
roz_api_base_url[RW]
roz_files_base_url[RW]
roz_secret_key[RW]
urn_namespaces[RW]

Public Class Methods

new() click to toggle source
# File lib/buweb_content_models/configuration.rb, line 13
def initialize
  @elasticsearch_index = 'buweb_test'  # this should get overwritten in your configuration file.
  @elasticsearch_settings = {
    analysis: {
      filter: {
        edge_ngram_filter: {
          type: "edgeNGram",
          min_gram: 2,
          max_gram: 35
        }
      },
      analyzer: {
        edge_ngram_analyzer: {
          tokenizer: 'lowercase',
          filter: ['edge_ngram_filter'],
          type: 'custom'
        }
      }
    }
  }
  @elasticsearch_mappings = {}
  @elasticsearchable_models = []
  @urn_namespaces = []
  @roz_api_base_url = 'https://api.biola.edu/assets/'
  @roz_files_base_url = 'https://assets.biola.edu/'
end

Public Instance Methods

elasticsearch_host() click to toggle source
# File lib/buweb_content_models/configuration.rb, line 44
def elasticsearch_host
  warn '[DEPRECATION] `elasticsearch_host` is deprecated. It is no longer used for anything.'
end
elasticsearch_host=(_host) click to toggle source
# File lib/buweb_content_models/configuration.rb, line 40
def elasticsearch_host=(_host)
  warn '[DEPRECATION] `elasticsearch_host=` is deprecated. It is no longer used for anything.'
end

Private Instance Methods

set_elasticsearch_mappings() click to toggle source
# File lib/buweb_content_models/configuration.rb, line 80
def set_elasticsearch_mappings
  elasticsearchable_models.each do |klass|
    @elasticsearch_mappings.merge! klass.mappings.to_hash
  end
  @_mappings_have_been_set = true
end
set_elasticsearchable_models() click to toggle source

Deprecated: this is no longer in use as we are defining the models manually

# File lib/buweb_content_models/configuration.rb, line 61
def set_elasticsearchable_models
  # inspired by http://goo.gl/RJk2yK
  dir = File.expand_path('../../buweb',  __FILE__)
  Dir.glob(File.join("#{dir}/*.rb")).each do |path|
    model_filename = File.basename(path, ".rb") # Example: "academic_program"

    begin
      klass = Kernel.const_get model_filename.classify
    rescue NameError
      # Not sure this really needs to throw an error or if it should just keep going
      require(path) ? retry : raise(RuntimeError, "Cannot load class '#{klass}' from filename: '#{model_filename}'")
    end

    next unless klass.respond_to?(:__elasticsearch__)
    @elasticsearchable_models << klass
    @_models_have_been_set = true
  end
end