class ROM::CSV::Gateway
CSV
gateway interface
@api public
Attributes
datasets[R]
@api private
options[R]
@api private
path[R]
@api private
Public Class Methods
new(path, options = {})
click to toggle source
Expect a path to a single csv file which will be registered by rom to the given name or :default as the gateway.
Uses CSV.table which passes the following csv options:
-
headers: true
-
converters: numeric
-
header_converters: :symbol
@param path [String] path to csv @param options [Hash] options passed to CSV.table
@api private
@see CSV.table
# File lib/rom/csv/gateway.rb, line 57 def initialize(path, options = {}) @datasets = {} @path = path @options = options @connection = ::CSV.table(path, options).by_row! end
Public Instance Methods
[](name)
click to toggle source
Return dataset with the given name
@param name [String] dataset name @return [Dataset]
@api public
# File lib/rom/csv/gateway.rb, line 70 def [](name) datasets[name] end
dataset(name)
click to toggle source
Register a dataset in the gateway
If dataset already exists it will be returned
@param name [String] dataset name @return [Dataset]
@api public
# File lib/rom/csv/gateway.rb, line 82 def dataset(name) datasets[name] = Dataset.new(connection, dataset_options) end
dataset?(name)
click to toggle source
Check if dataset exists
@param name [String] dataset name
@api public
# File lib/rom/csv/gateway.rb, line 91 def dataset?(name) datasets.key?(name) end
Private Instance Methods
dataset_options()
click to toggle source
# File lib/rom/csv/gateway.rb, line 97 def dataset_options { path: path, file_options: options } end