Class: ROM::CSV::Gateway
- Inherits:
-
Gateway
- Object
- Gateway
- ROM::CSV::Gateway
- Defined in:
- lib/rom/csv/gateway.rb
Overview
CSV gateway interface
Instance Method Summary collapse
-
#[](name) ⇒ Dataset
Return dataset with the given name.
-
#dataset(name) ⇒ Dataset
Register a dataset in the gateway.
-
#dataset?(name) ⇒ Boolean
Check if dataset exists.
-
#initialize(path, options = {}) ⇒ Gateway
constructor
private
Expect a path to a single csv file which will be registered by rom to the given name or :default as the gateway.
Constructor Details
#initialize(path, options = {}) ⇒ Gateway
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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
57 58 59 60 61 62 |
# File 'lib/rom/csv/gateway.rb', line 57 def initialize(path, = {}) @datasets = {} @path = path @options = @connection = ::CSV.table(path, ).by_row! end |
Instance Method Details
#[](name) ⇒ Dataset
Return dataset with the given name
70 71 72 |
# File 'lib/rom/csv/gateway.rb', line 70 def [](name) datasets[name] end |
#dataset(name) ⇒ Dataset
Register a dataset in the gateway
If dataset already exists it will be returned
82 83 84 |
# File 'lib/rom/csv/gateway.rb', line 82 def dataset(name) datasets[name] = Dataset.new(connection, ) end |
#dataset?(name) ⇒ Boolean
Check if dataset exists
91 92 93 |
# File 'lib/rom/csv/gateway.rb', line 91 def dataset?(name) datasets.key?(name) end |