lib/rom/sql/gateway.rb in rom-sql-0.7.0 vs lib/rom/sql/gateway.rb in rom-sql-0.8.0
- old
+ new
@@ -28,24 +28,10 @@
# @return [Object] logger
#
# @api public
attr_reader :logger
- # Returns a list of datasets inferred from table names
- #
- # @return [Array] array with table names
- #
- # @api public
- attr_reader :schema
-
- # @param [String,Symbol] scheme
- #
- # @api public
- def self.database_file?(scheme)
- scheme.to_s.include?('sqlite')
- end
-
# SQL gateway interface
#
# @overload connect(uri, options)
# Connects to database via uri passing options
#
@@ -68,11 +54,10 @@
def initialize(uri, options = {})
repo_options = self.class.option_definitions.names
conn_options = options.reject { |k, _| repo_options.include?(k) }
@connection = connect(uri, conn_options)
- @schema = connection.tables
add_extensions(Array(options[:extensions])) if options[:extensions]
super(uri, options.reject { |k, _| conn_options.keys.include?(k) })
self.class.instance = self
@@ -149,9 +134,32 @@
klass.send(:include, ext) if ext
end
klass
+ end
+
+ # Create a table using the configured connection
+ #
+ # @api public
+ def create_table(*args, &block)
+ connection.create_table(*args, &block)
+ end
+
+ # Drops a table
+ #
+ # @api public
+ def drop_table(*args, &block)
+ connection.drop_table(*args, &block)
+ end
+
+ # Returns a list of datasets inferred from table names
+ #
+ # @return [Array] array with table names
+ #
+ # @api public
+ def schema
+ @schema ||= connection.tables
end
private
# Connect to database or reuse established connection instance