Class: Quickbase::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/classes/connection.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection



18
19
20
21
22
23
# File 'lib/classes/connection.rb', line 18

def initialize(options = {})
  [:username, :password, :hours, :apptoken, :dbid, :org].each do |attr|
    instance_variable_set "@#{attr}", (options[attr].nil? ? Quickbase::Connection.send(attr) : options[attr])
  end
  instance_variable_set "@org", "www" if org.nil?
end

Class Attribute Details

.apptoken=(value) ⇒ Object (writeonly)

Sets the attribute apptoken

Parameters:

  • value

    the value to set the attribute apptoken to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def apptoken=(value)
  @apptoken = value
end

.dbid=(value) ⇒ Object (writeonly)

Sets the attribute dbid

Parameters:

  • value

    the value to set the attribute dbid to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def dbid=(value)
  @dbid = value
end

.hours=(value) ⇒ Object (writeonly)

Sets the attribute hours

Parameters:

  • value

    the value to set the attribute hours to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def hours=(value)
  @hours = value
end

.org=(value) ⇒ Object (writeonly)

Sets the attribute org

Parameters:

  • value

    the value to set the attribute org to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def org=(value)
  @org = value
end

.password=(value) ⇒ Object (writeonly)

Sets the attribute password

Parameters:

  • value

    the value to set the attribute password to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def password=(value)
  @password = value
end

.username=(value) ⇒ Object (writeonly)

Sets the attribute username

Parameters:

  • value

    the value to set the attribute username to.



4
5
6
# File 'lib/classes/connection.rb', line 4

def username=(value)
  @username = value
end

Instance Attribute Details

#apptokenObject (readonly)

Returns the value of attribute apptoken



6
7
8
# File 'lib/classes/connection.rb', line 6

def apptoken
  @apptoken
end

#dbidObject (readonly)

Returns the value of attribute dbid



6
7
8
# File 'lib/classes/connection.rb', line 6

def dbid
  @dbid
end

#hoursObject (readonly)

Returns the value of attribute hours



6
7
8
# File 'lib/classes/connection.rb', line 6

def hours
  @hours
end

#orgObject (readonly)

Returns the value of attribute org



6
7
8
# File 'lib/classes/connection.rb', line 6

def org
  @org
end

#passwordObject (readonly)

Returns the value of attribute password



6
7
8
# File 'lib/classes/connection.rb', line 6

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username



6
7
8
# File 'lib/classes/connection.rb', line 6

def username
  @username
end

Class Method Details

.expectant_reader(*attributes) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/classes/connection.rb', line 8

def self.expectant_reader(*attributes)
  attributes.each do |attribute|
    (class << self; self; end).send(:define_method, attribute) do
      attribute_value = instance_variable_get("@#{attribute}")
      attribute_value
    end
  end
end

Instance Method Details

#apiObject



40
41
42
# File 'lib/classes/connection.rb', line 40

def api
  Quickbase::Api.new(self)
end

#httpObject



36
37
38
# File 'lib/classes/connection.rb', line 36

def http
  Quickbase::Http.new(instantiate)
end

#instantiateObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/classes/connection.rb', line 25

def instantiate
  config = {
    :username => username,
    :password => password,
    :hours => hours,
    :apptoken => apptoken,
    :dbid => dbid,
    :org => org
  }
end