Class: Scalastic::Config
- Inherits:
-
Object
- Object
- Scalastic::Config
- Defined in:
- lib/scalastic/config.rb
Instance Attribute Summary collapse
-
#partition_prefix ⇒ Object
Returns the value of attribute partition_prefix.
-
#partition_selector ⇒ Object
Returns the value of attribute partition_selector.
-
#partition_selector_type ⇒ Object
Returns the value of attribute partition_selector_type.
Class Method Summary collapse
Instance Method Summary collapse
- #get_partition_id(alias_name) ⇒ Object
- #index_endpoint(partition_id) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #partition_selector_mapping ⇒ Object
- #search_endpoint(partition_id) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 |
# File 'lib/scalastic/config.rb', line 11 def initialize @partition_prefix = 'scalastic' @partition_selector = 'scalastic_partition_id' @partition_selector_type = 'long' end |
Instance Attribute Details
#partition_prefix ⇒ Object
Returns the value of attribute partition_prefix.
3 4 5 |
# File 'lib/scalastic/config.rb', line 3 def partition_prefix @partition_prefix end |
#partition_selector ⇒ Object
Returns the value of attribute partition_selector.
4 5 6 |
# File 'lib/scalastic/config.rb', line 4 def partition_selector @partition_selector end |
#partition_selector_type ⇒ Object
Returns the value of attribute partition_selector_type.
5 6 7 |
# File 'lib/scalastic/config.rb', line 5 def partition_selector_type @partition_selector_type end |
Class Method Details
.default ⇒ Object
7 8 9 |
# File 'lib/scalastic/config.rb', line 7 def self.default @default ||= new end |
Instance Method Details
#get_partition_id(alias_name) ⇒ Object
25 26 27 28 |
# File 'lib/scalastic/config.rb', line 25 def get_partition_id(alias_name) m = partition_regex.match(alias_name) m && m[1] end |
#index_endpoint(partition_id) ⇒ Object
17 18 19 |
# File 'lib/scalastic/config.rb', line 17 def index_endpoint(partition_id) "#{partition_prefix}_#{partition_id}_index" end |
#partition_selector_mapping ⇒ Object
46 47 48 49 50 |
# File 'lib/scalastic/config.rb', line 46 def partition_selector_mapping parts = partition_selector.to_s.split('.').reverse field = parts.shift parts.reduce(field => {type: partition_selector_type}){|acc, p| {p => {type: 'object', properties: acc}}} end |
#search_endpoint(partition_id) ⇒ Object
21 22 23 |
# File 'lib/scalastic/config.rb', line 21 def search_endpoint(partition_id) "#{partition_prefix}_#{partition_id}_search" end |