Class: ActiveRecord::ConnectionAdapters::Elasticsearch::CloneTableDefinition
- Inherits:
-
TableDefinition
- Object
- TableDefinition
- ActiveRecord::ConnectionAdapters::Elasticsearch::CloneTableDefinition
- Defined in:
- lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#alias(name, force: false, **options, &block) ⇒ Object
we can use +alias+ here, since the instance method is not a reserved keyword!.
-
#aliases ⇒ Array
returns an array with all +TableAliasDefinition+.
-
#initialize(conn, name, target, settings: nil, aliases: nil, **opts) ⇒ CloneTableDefinition
constructor
A new instance of CloneTableDefinition.
- #remove_alias(name) ⇒ Object
- #remove_setting(name) ⇒ Object
-
#setting(name, value, force: false, **options, &block) ⇒ Object
DEFINITION METHODS #.
-
#settings ⇒ Array
returns an array with all +TableSettingDefinition+.
Constructor Details
#initialize(conn, name, target, settings: nil, aliases: nil, **opts) ⇒ CloneTableDefinition
Returns a new instance of CloneTableDefinition.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 12 def initialize(conn, name, target, settings: nil, aliases: nil, **opts) super(conn, name, **opts) @target = target @settings = HashWithIndifferentAccess.new @aliases = HashWithIndifferentAccess.new # before assigning new settings, we need to resolve some defaults assign_default_clone_settings! transform_settings!(settings) if settings.present? transform_aliases!(aliases) if aliases.present? end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 10 def target @target end |
Instance Method Details
#alias(name, force: false, **options, &block) ⇒ Object
we can use +alias+ here, since the instance method is not a reserved keyword!
56 57 58 59 60 61 62 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 56 def alias(name, force: false, **, &block) raise ArgumentError, "you cannot define an already defined alias '#{name}'." if @aliases.key?(name) && !force?(force) @aliases[name] = new_alias_definition(name, **, &block) self end |
#aliases ⇒ Array
returns an array with all +TableAliasDefinition+.
34 35 36 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 34 def aliases @aliases.values end |
#remove_alias(name) ⇒ Object
64 65 66 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 64 def remove_alias(name) @aliases.delete name end |
#remove_setting(name) ⇒ Object
50 51 52 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 50 def remove_setting(name) @settings.delete name end |
#setting(name, value, force: false, **options, &block) ⇒ Object
DEFINITION METHODS #
42 43 44 45 46 47 48 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 42 def setting(name, value, force: false, **, &block) raise ArgumentError, "you cannot define an already defined setting '#{name}'!" if @settings.key?(name) && !force?(force) @settings[name] = new_setting_definition(name, value, **, &block) self end |
#settings ⇒ Array
returns an array with all +TableSettingDefinition+.
28 29 30 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/clone_table_definition.rb', line 28 def settings @settings.values end |