Class: ActiveRecord::ConnectionAdapters::Elasticsearch::TableDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::Elasticsearch::TableDefinition
- Includes:
- ColumnMethods
- Defined in:
- lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb
Direct Known Subclasses
CloneTableDefinition, CreateTableDefinition, UpdateTableDefinition
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#assign ⇒ Object
yields provided block with self to change the table and collect table information returns self, to chain this method.
- #exec! ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(conn, name, **opts) ⇒ TableDefinition
constructor
A new instance of TableDefinition.
-
#primary_key(name, type = :primary_key, **options) ⇒ Object
included
from ColumnMethods
Appends a primary key definition to the table definition.
Constructor Details
#initialize(conn, name, **opts) ⇒ TableDefinition
22 23 24 25 26 27 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 22 def initialize(conn, name, **opts) @conn = conn @name = name @opts = opts @failed = false end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
18 19 20 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 18 def conn @conn end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 19 def name @name end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
20 21 22 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 20 def opts @opts end |
Instance Method Details
#assign ⇒ Object
yields provided block with self to change the table and collect table information returns self, to chain this method
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 31 def assign # if before assign fails, we don't want to continue yielding! _before_assign begin yield self rescue => e @failed = false _rescue_assign raise e end _after_assign end |
#exec! ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 46 def exec! # if before exec fails, we don't want to continue with execution! _before_exec begin _exec rescue => e @failed = false _rescue_exec raise e end _after_exec end |
#failed? ⇒ Boolean
61 62 63 |
# File 'lib/active_record/connection_adapters/elasticsearch/schema_definitions/table_definition.rb', line 61 def failed? @failed end |
#primary_key(name, type = :primary_key, **options) ⇒ Object Originally defined in module ColumnMethods
Appends a primary key definition to the table definition. Can be called multiple times, but this is probably not a good idea.