Class: Ethel::Sources::Sequel
- Inherits:
-
Source
- Object
- Source
- Ethel::Sources::Sequel
- Defined in:
- lib/ethel/sources/sequel.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(*args) ⇒ Sequel
constructor
A new instance of Sequel.
- #schema ⇒ Object
Constructor Details
#initialize(*args) ⇒ Sequel
Returns a new instance of Sequel.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/ethel/sources/sequel.rb', line 4 def initialize(*args) if args.length == 1 @dataset = args[0] @database = @dataset.db else @database = ::Sequel.connect(*args[1..-1]) @dataset = @database[args[0]] @dataset_arg = args[0] end end |
Instance Method Details
#each(&block) ⇒ Object
26 27 28 |
# File 'lib/ethel/sources/sequel.rb', line 26 def each(&block) @dataset.each(&block) end |
#schema ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ethel/sources/sequel.rb', line 15 def schema table = if @dataset_arg.nil? @dataset.first_source_table else @dataset_arg end @database.schema(table) end |