Class: Esse::Config
- Inherits:
-
Object
- Object
- Esse::Config
- Defined in:
- lib/esse/config.rb
Overview
Constant Summary collapse
- DEFAULT_CLUSTER_ID =
:default
- ATTRIBUTES =
%i[indices_directory bulk_wait_interval].freeze
Instance Attribute Summary collapse
-
#bulk_wait_interval ⇒ Object
wait a given period between posting pages to give Elasticsearch time to catch up.
-
#indices_directory ⇒ Object
The location of the indices.
Instance Method Summary collapse
-
#cli_event_listeners? ⇒ Boolean
:nodoc: This is only used by rspec to disable the CLI print out.
- #cluster(key = DEFAULT_CLUSTER_ID, **options) ⇒ Object (also: #clusters)
- #cluster_ids ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(arg) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
54 55 56 57 58 59 |
# File 'lib/esse/config.rb', line 54 def initialize self.indices_directory = 'app/indices' self.bulk_wait_interval = 0.1 @clusters = {} cluster(DEFAULT_CLUSTER_ID) # initialize the :default client end |
Instance Attribute Details
#bulk_wait_interval ⇒ Object
wait a given period between posting pages to give Elasticsearch time to catch up.
52 53 54 |
# File 'lib/esse/config.rb', line 52 def bulk_wait_interval @bulk_wait_interval end |
#indices_directory ⇒ Object
The location of the indices. Defaults to the ‘app/indices`
49 50 51 |
# File 'lib/esse/config.rb', line 49 def indices_directory @indices_directory end |
Instance Method Details
#cli_event_listeners? ⇒ Boolean
:nodoc: This is only used by rspec to disable the CLI print out.
101 102 103 |
# File 'lib/esse/config.rb', line 101 def cli_event_listeners? true end |
#cluster(key = DEFAULT_CLUSTER_ID, **options) ⇒ Object Also known as: clusters
65 66 67 68 69 70 71 72 73 |
# File 'lib/esse/config.rb', line 65 def cluster(key = DEFAULT_CLUSTER_ID, **) return unless key id = key.to_sym (@clusters[id] ||= Cluster.new(id: id)).tap do |c| c.assign() if yield c if block_given? end end |
#cluster_ids ⇒ Object
61 62 63 |
# File 'lib/esse/config.rb', line 61 def cluster_ids @clusters.keys end |
#load(arg) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/esse/config.rb', line 84 def load(arg) case arg when Hash assign(arg) when File, Pathname assign(YAML.load_file(arg)) when String return load(Pathname.new(arg)) if File.exist?(arg) assign(YAML.safe_load(arg)) else raise ArgumentError, printf('could not load configuration using: %p', val) end end |