Module: CustomAttributes

Defined in:
lib/custom_attributes.rb,
lib/custom_attributes/version.rb,
lib/custom_attributes/field_type.rb,
lib/custom_attributes/search_query.rb,
lib/custom_attributes/field_types/list.rb,
lib/custom_attributes/custom_field_value.rb,
lib/custom_attributes/search_query_field.rb,
lib/custom_attributes/concerns/searchable.rb,
lib/custom_attributes/field_types/numeric.rb,
lib/custom_attributes/fluent_search_query.rb,
lib/custom_attributes/field_types/unbounded.rb,
lib/custom_attributes/field_types/int_field_type.rb,
lib/custom_attributes/field_types/bool_field_type.rb,
lib/custom_attributes/field_types/date_field_type.rb,
lib/custom_attributes/field_types/list_field_type.rb,
lib/custom_attributes/field_types/text_field_type.rb,
lib/custom_attributes/acts_as/acts_as_custom_field.rb,
lib/custom_attributes/acts_as/acts_as_custom_value.rb,
lib/custom_attributes/acts_as/acts_as_customizable.rb,
lib/custom_attributes/field_types/float_field_type.rb,
lib/custom_attributes/field_types/string_field_type.rb,
lib/custom_attributes/api/custom_attributes_controller_helper.rb

Defined Under Namespace

Modules: ActsAsCustomField, ActsAsCustomValue, ActsAsCustomizable, ControllerHelper, Searchable Classes: BoolFieldType, CustomFieldValue, DateFieldType, FieldType, FloatFieldType, FluentSearchQuery, IntFieldType, List, ListFieldType, Numeric, SearchQuery, SearchQueryField, StringFieldType, TextFieldType, Unbounded

Constant Summary collapse

VERSION =
'0.6.2'.freeze

Class Method Summary collapse

Class Method Details

.after_configurationObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/custom_attributes.rb', line 48

def self.after_configuration
  # Set up ElasticSearch
  uri = URI(@config[:search_host])

  if @config[:search_user].present? && @config[:search_pass].present?
    host = "#{uri.scheme}://#{@config[:search_user]}:#{@config[:search_pass]}@#{uri.host}"
  else
    host = "#{uri.scheme}://#{uri.host}"
  end

  host = "#{host}:#{uri.port}" if uri.port.present?

  Elasticsearch::Model.client = Elasticsearch::Client.new host: host
end

.configObject



44
45
46
# File 'lib/custom_attributes.rb', line 44

def self.config
  @config
end

.configure(opts = {}) ⇒ Object

Configure through hash



38
39
40
41
42
# File 'lib/custom_attributes.rb', line 38

def self.configure(opts = {})
  opts.each { |k, v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym }

  after_configuration
end