Module: Stretchy::Utils::Configuration
- Included in:
- Stretchy
- Defined in:
- lib/stretchy/utils/configuration.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#client(options = {}) ⇒ Object
Returns the value of attribute client.
-
#index_name ⇒ Object
Returns the value of attribute index_name.
-
#log_color ⇒ Object
Returns the value of attribute log_color.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #client_options ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #connect(options = {}) ⇒ Object
- #log(*args) ⇒ Object
- #log_handler ⇒ Object
- #set_default_configuration ⇒ Object
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def adapter @adapter end |
#client(options = {}) ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def client @client end |
#index_name ⇒ Object
Returns the value of attribute index_name.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def index_name @index_name end |
#log_color ⇒ Object
Returns the value of attribute log_color.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def log_color @log_color end |
#log_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def logger @logger end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/stretchy/utils/configuration.rb', line 5 def url @url end |
Class Method Details
.extended(base) ⇒ Object
7 8 9 |
# File 'lib/stretchy/utils/configuration.rb', line 7 def self.extended(base) base.set_default_configuration end |
Instance Method Details
#client_options ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/stretchy/utils/configuration.rb', line 22 def Hash[ index_name: index_name, log: !!logger, logger: logger, adapter: adapter, url: url ] end |
#configure {|_self| ... } ⇒ Object
11 12 13 |
# File 'lib/stretchy/utils/configuration.rb', line 11 def configure yield self end |
#connect(options = {}) ⇒ Object
32 33 34 |
# File 'lib/stretchy/utils/configuration.rb', line 32 def connect( = {}) @client = Elasticsearch::Client.new(.merge()) end |
#log(*args) ⇒ Object
44 45 46 |
# File 'lib/stretchy/utils/configuration.rb', line 44 def log(*args) args.each {|arg| log_handler.log(arg) } end |
#log_handler ⇒ Object
40 41 42 |
# File 'lib/stretchy/utils/configuration.rb', line 40 def log_handler @log_handler ||= Stretchy::Utils::Logger.new(logger, log_level, log_color) end |
#set_default_configuration ⇒ Object
15 16 17 18 19 20 |
# File 'lib/stretchy/utils/configuration.rb', line 15 def set_default_configuration self.index_name = 'myapp' self.adapter = :excon self.url = ENV['ELASTICSEARCH_URL'] self.log_level = :silence end |