Class: Tableau::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/tableau_ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Client

user_id, password, site


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tableau_ruby/client.rb', line 9

def initialize(args={})
  @host = args[:host] || Tableau.host
  @admin_name = args[:admin_name] || Tableau.admin_name
  @admin_password = args[:admin_password] || Tableau.admin_password
  @content_url = args[:content_url] || ""

  setup_connection

  @token = (args[:user_name])
  @site_id = get_site_id

  setup_subresources

  @user = Tableau::User.new(self, @users.find_by(site_id: @site_id, name: args[:user_name])['user']) if args.include? :user_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

Delegate user methods from the client. This saves having to call client.user every time for resources on the default user.


33
34
35
36
37
38
39
# File 'lib/tableau_ruby/client.rb', line 33

def method_missing(method_name, *args, &block)
  if user.respond_to?(method_name)
    user.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#admin_nameObject (readonly)

Returns the value of attribute admin_name


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def admin_name
  @admin_name
end

#connObject (readonly)

Returns the value of attribute conn


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def conn
  @conn
end

#content_urlObject

Returns the value of attribute content_url


6
7
8
# File 'lib/tableau_ruby/client.rb', line 6

def content_url
  @content_url
end

#datasourcesObject (readonly)

Returns the value of attribute datasources


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def datasources
  @datasources
end

#groupsObject (readonly)

Returns the value of attribute groups


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def groups
  @groups
end

#hostObject (readonly)

Returns the value of attribute host


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def host
  @host
end

#projectsObject (readonly)

Returns the value of attribute projects


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def projects
  @projects
end

#site_idObject

Returns the value of attribute site_id


6
7
8
# File 'lib/tableau_ruby/client.rb', line 6

def site_id
  @site_id
end

#sitesObject (readonly)

Returns the value of attribute sites


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def sites
  @sites
end

#tokenObject

Returns the value of attribute token


6
7
8
# File 'lib/tableau_ruby/client.rb', line 6

def token
  @token
end

#userObject (readonly)

Returns the value of attribute user


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def user
  @user
end

#usersObject (readonly)

Returns the value of attribute users


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def users
  @users
end

#workbooksObject (readonly)

Returns the value of attribute workbooks


5
6
7
# File 'lib/tableau_ruby/client.rb', line 5

def workbooks
  @workbooks
end

Instance Method Details

#inspectObject


25
26
27
# File 'lib/tableau_ruby/client.rb', line 25

def inspect
  "<Tableau::Client @host=#{@host} @admin_name=#{@admin_name} @content_url=#{@content_url} @site_id=#{@site_id} @user=#{@user}>"
end

#respond_to?(method_name, include_private = false) ⇒ Boolean


41
42
43
44
45
46
47
# File 'lib/tableau_ruby/client.rb', line 41

def respond_to?(method_name, include_private=false)
  if user.respond_to?(method_name, include_private)
    true
  else
    super
  end
end