Class: JayAPI::Elasticsearch::Indices::Settings::Blocks
- Inherits:
-
Object
- Object
- JayAPI::Elasticsearch::Indices::Settings::Blocks
- Defined in:
- lib/jay_api/elasticsearch/indices/settings/blocks.rb
Overview
Represents the block settings of an Elasticsearch index.
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#initialize(settings) ⇒ Blocks
constructor
A new instance of Blocks.
-
#write=(value) ⇒ Object
Sets the index’s
writeblock to the given value. -
#write_blocked? ⇒ Boolean
True if the Index’s write block has been set to true, false otherwise.
Constructor Details
#initialize(settings) ⇒ Blocks
Returns a new instance of Blocks.
13 14 15 |
# File 'lib/jay_api/elasticsearch/indices/settings/blocks.rb', line 13 def initialize(settings) @settings = settings end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
9 10 11 |
# File 'lib/jay_api/elasticsearch/indices/settings/blocks.rb', line 9 def settings @settings end |
Instance Method Details
#write=(value) ⇒ Object
Sets the index’s write block to the given value. When the write block is set to true the index’s data is read-only, but the index’s settings can still be changed. This allows maintenance tasks to still be performed on the index.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jay_api/elasticsearch/indices/settings/blocks.rb', line 31 def write=(value) unless [true, false].include?(value) raise ArgumentError, "Expected 'value' to be true or false, #{value.class} given" end return if write_blocked? == value settings.transport_client.indices.put_settings( index: settings.index_name, body: { 'blocks.write' => value } ) end |
#write_blocked? ⇒ Boolean
Returns True if the Index’s write block has been set to true, false otherwise.
19 20 21 |
# File 'lib/jay_api/elasticsearch/indices/settings/blocks.rb', line 19 def write_blocked? blocks_settings.fetch('write') == 'true' end |