Class: Esse::IndexSetting
- Inherits:
-
Object
- Object
- Esse::IndexSetting
- Defined in:
- lib/esse/index_setting.rb
Overview
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(body: {}, paths: [], globals: nil) ⇒ IndexSetting
constructor
A new instance of IndexSetting.
-
#to_h ⇒ Object
This method will be overwrited when passing a block during the settings defination on index class.
Constructor Details
#initialize(body: {}, paths: [], globals: nil) ⇒ IndexSetting
Returns a new instance of IndexSetting.
10 11 12 13 14 |
# File 'lib/esse/index_setting.rb', line 10 def initialize(body: {}, paths: [], globals: nil) @globals = globals || -> { {} } @paths = Array(paths) @settings = body end |
Instance Method Details
#body ⇒ Object
32 33 34 35 36 |
# File 'lib/esse/index_setting.rb', line 32 def body global = HashUtils.deep_transform_keys(@globals.call, &:to_sym) local = HashUtils.deep_transform_keys(to_h, &:to_sym) HashUtils.deep_merge(global, local) end |
#to_h ⇒ Object
26 27 28 29 30 |
# File 'lib/esse/index_setting.rb', line 26 def to_h return @settings unless @settings.empty? from_template || @settings end |