class TableauServerClient::Resources::Resource
Public Class Methods
attr_reader(*vars)
click to toggle source
Calls superclass method
# File lib/tableau_server_client/resources/resource.rb, line 13 def self.attr_reader(*vars) @attributes ||= [] @attributes.concat (vars.map { |v| Attribute.new(v.to_s) }) super(*vars) end
attributes()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 19 def self.attributes @attributes end
extract_attributes(xml)
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 36 def self.extract_attributes(xml) unless xml.name == resource_name raise "Element name (#{xml.name}) does not match with resource name (#{resource_name})" end attributes.select {|a| xml.key?(a.camelCase) }.map {|a| [a.to_sym, xml[a.camelCase]] }.to_h end
extract_site_path(path)
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 43 def self.extract_site_path(path) p = path.split('/') p.slice(p.index('sites'),2).join('/') end
location(prefix, id=nil, filter: [])
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 31 def self.location(prefix, id=nil, filter: []) path = [prefix, plural_resource_name, id].compact.join("/") Location.new(self, path, filter.empty? ? {} : {filter: filter.join(',')}) end
new(client, path, attributes)
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 7 def initialize(client, path, attributes) @client = client @path = path attributes.each {|k,v| instance_variable_set("@#{k}",v) } end
plural_resource_name()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 27 def self.plural_resource_name "#{self.resource_name}s" end
resource_name()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 23 def self.resource_name self.name.split("::").last.sub(/./){ $&.downcase } end
Public Instance Methods
attributes()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 48 def attributes self.class.attributes end
delete!()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 72 def delete! @client.delete self end
location(query_params: {})
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 56 def location(query_params: {}) Location.new(self, path, query_params) end
path()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 52 def path @path end
server_url()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 68 def server_url @client.server_url end
site_id()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 64 def site_id site_path.split('/')[1] end
site_path()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 60 def site_path self.class.extract_site_path(path) end
Private Instance Methods
client()
click to toggle source
# File lib/tableau_server_client/resources/resource.rb, line 99 def client @client end