Module: Hyperloop::AutoCreate
- Included in:
- Connection, Connection::QueuedMessage
- Defined in:
- lib/hyper-operation/transport/connection.rb
Instance Method Summary collapse
Instance Method Details
#create_table(*args, &block) ⇒ Object
16 17 18 |
# File 'lib/hyper-operation/transport/connection.rb', line 16 def create_table(*args, &block) connection.create_table(table_name, *args, &block) if needs_init? end |
#needs_init? ⇒ Boolean
12 13 14 |
# File 'lib/hyper-operation/transport/connection.rb', line 12 def needs_init? Hyperloop.transport != :none && Hyperloop.on_server? && !table_exists? end |
#table_exists? ⇒ Boolean
3 4 5 6 7 8 9 10 |
# File 'lib/hyper-operation/transport/connection.rb', line 3 def table_exists? # works with both rails 4 and 5 without deprecation warnings if connection.respond_to?(:data_sources) connection.data_sources.include?(table_name) else connection.tables.include?(table_name) end end |