Class: TableauServerClient::Resources::Datasource::DatasourceContent
- Inherits:
-
Object
- Object
- TableauServerClient::Resources::Datasource::DatasourceContent
- Defined in:
- lib/tableau_server_client/resources/datasource.rb
Defined Under Namespace
Classes: NamedConnection
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #custom_queries ⇒ Object
-
#initialize(xml) ⇒ DatasourceContent
constructor
A new instance of DatasourceContent.
- #named_connections ⇒ Object
- #tables ⇒ Object
Constructor Details
#initialize(xml) ⇒ DatasourceContent
Returns a new instance of DatasourceContent.
60 61 62 |
# File 'lib/tableau_server_client/resources/datasource.rb', line 60 def initialize(xml) @xml = xml end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
64 65 66 |
# File 'lib/tableau_server_client/resources/datasource.rb', line 64 def xml @xml end |
Instance Method Details
#custom_queries ⇒ Object
73 74 75 |
# File 'lib/tableau_server_client/resources/datasource.rb', line 73 def custom_queries relations.select {|r| r['type'] == 'text' }.map {|c| c.content } end |
#named_connections ⇒ Object
67 68 69 70 71 |
# File 'lib/tableau_server_client/resources/datasource.rb', line 67 def named_connections xml.xpath('//named-connection').map do |c| NamedConnection.new(c.first_element_child['class'], c['caption'], c['name']) end end |
#tables ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/tableau_server_client/resources/datasource.rb', line 77 def tables tables = [] redshift_connections = named_connections.select {|c| c.class == 'redshift' }.map {|c| c.name } relations.each do |rel| next unless redshift_connections.include? rel['connection'] case rel['type'] when 'table' tables << rel['table'] when 'text' tables.concat extract_tables(rel.content) else next end end tables.map {|t| t.gsub(/[\[\]")]/, '')}.uniq end |