Class: Broker::Session
- Inherits:
-
Object
- Object
- Broker::Session
- Defined in:
- lib/broker/session.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
Instance Method Summary collapse
- #field_names(table) ⇒ Object
- #fire_event ⇒ Object
-
#initialize(opt = {}) ⇒ Session
constructor
A new instance of Session.
- #qb_ready?(name) ⇒ Boolean
- #sign_out ⇒ Object
Constructor Details
#initialize(opt = {}) ⇒ Session
Returns a new instance of Session.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/broker/session.rb', line 8 def initialize(opt={}) @app = Broker.lookup_appname(opt[:app]) @ext = Broker.[:file_ext] credentials = { "username" => Broker.secrets['USERNAME'], "password" => Broker.secrets['PASSWORD'], "appname" => @app, "org" => Broker.secrets['ORG'], "apptoken" => opt[:token] || Broker.secrets['TOKEN'] } begin @client = QuickBase::Client.init(credentials) rescue => e puts e. #raise ArgumentError ensure # We successfully logged into quickbase, but supplied an invalid app name if @client && @client.errcode == "32" @client.signOut raise ArgumentError end end end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/broker/session.rb', line 6 def app @app end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/broker/session.rb', line 6 def client @client end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
6 7 8 |
# File 'lib/broker/session.rb', line 6 def ext @ext end |
Instance Method Details
#field_names(table) ⇒ Object
50 51 52 53 54 |
# File 'lib/broker/session.rb', line 50 def field_names(table) table &&= table.to_s db = Broker.tables[@app]['tables'][table] db && @client.getFieldNames(db, "", true) end |
#fire_event ⇒ Object
34 35 36 |
# File 'lib/broker/session.rb', line 34 def fire_event raise NotImplementedError end |
#qb_ready?(name) ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'lib/broker/session.rb', line 42 def qb_ready?(name) app_name = Broker.lookup_appname(name) unless app_name == @client.dbname return app_name && change_app(app_name, name) end true end |
#sign_out ⇒ Object
38 39 40 |
# File 'lib/broker/session.rb', line 38 def sign_out @client.signOut end |