Class: Mode::Connector::DataSource
- Inherits:
-
Object
- Object
- Mode::Connector::DataSource
- Defined in:
- lib/mode/connector/data_source.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
Instance Method Summary collapse
- #adapter ⇒ Object
- #database ⇒ Object
- #host ⇒ Object
-
#initialize(name, props = {}) ⇒ DataSource
constructor
A new instance of DataSource.
- #jdbc? ⇒ Boolean
- #mysql? ⇒ Boolean
- #password ⇒ Object
- #port ⇒ Object
- #postgres? ⇒ Boolean
- #redshift? ⇒ Boolean
- #select(query, &block) ⇒ Object
- #sqlserver? ⇒ Boolean
- #ssl ⇒ Object (also: #ssl?)
- #username ⇒ Object
- #vertica? ⇒ Boolean
Constructor Details
#initialize(name, props = {}) ⇒ DataSource
Returns a new instance of DataSource.
12 13 14 15 |
# File 'lib/mode/connector/data_source.rb', line 12 def initialize(name, props = {}) @name = name @props = props end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
10 11 12 |
# File 'lib/mode/connector/data_source.rb', line 10 def connection @connection end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/mode/connector/data_source.rb', line 7 def name @name end |
#props ⇒ Object (readonly)
Returns the value of attribute props.
8 9 10 |
# File 'lib/mode/connector/data_source.rb', line 8 def props @props end |
Instance Method Details
#adapter ⇒ Object
17 18 19 |
# File 'lib/mode/connector/data_source.rb', line 17 def adapter props['adapter'] end |
#database ⇒ Object
37 38 39 |
# File 'lib/mode/connector/data_source.rb', line 37 def database props['database'] end |
#host ⇒ Object
29 30 31 |
# File 'lib/mode/connector/data_source.rb', line 29 def host props['host'] end |
#jdbc? ⇒ Boolean
57 58 59 |
# File 'lib/mode/connector/data_source.rb', line 57 def jdbc? adapter.start_with?('jdbc') end |
#mysql? ⇒ Boolean
77 78 79 |
# File 'lib/mode/connector/data_source.rb', line 77 def mysql? ['mysql', 'mysql2', 'jdbc:mysql'].include?(adapter) end |
#password ⇒ Object
25 26 27 |
# File 'lib/mode/connector/data_source.rb', line 25 def password props['password'] end |
#port ⇒ Object
33 34 35 |
# File 'lib/mode/connector/data_source.rb', line 33 def port props['port'] end |
#postgres? ⇒ Boolean
73 74 75 |
# File 'lib/mode/connector/data_source.rb', line 73 def postgres? ['postgres', 'jdbc:postgresql'].include?(adapter) end |
#redshift? ⇒ Boolean
65 66 67 |
# File 'lib/mode/connector/data_source.rb', line 65 def redshift? ['redshift', 'jdbc:redshift'].include?(adapter) end |
#select(query, &block) ⇒ Object
46 47 48 49 |
# File 'lib/mode/connector/data_source.rb', line 46 def select(query, &block) log_connection_query(query) connection.dataset.fetch_rows(query, &block) end |
#sqlserver? ⇒ Boolean
69 70 71 |
# File 'lib/mode/connector/data_source.rb', line 69 def sqlserver? ['tiny_tds', 'jdbc:sqlserver'].include?(adapter) end |
#ssl ⇒ Object Also known as: ssl?
41 42 43 |
# File 'lib/mode/connector/data_source.rb', line 41 def ssl props['ssl'] end |
#username ⇒ Object
21 22 23 |
# File 'lib/mode/connector/data_source.rb', line 21 def username props['username'] end |
#vertica? ⇒ Boolean
61 62 63 |
# File 'lib/mode/connector/data_source.rb', line 61 def vertica? ['vertica', 'jdbc:vertica'].include?(adapter) end |