Method: QBFC::Session.open

Defined in:
lib/qbfc/session.rb

.open(*options, &block) ⇒ Object

Open a QBFC session. Takes options as a hash, and an optional block. Options are:

  • app_name: Name that the application sends to Quickbooks (used for allowing/denying access) (defaults to ‘Ruby QBFC Application’

  • app_id: Per the Quickbooks SDK (QBFC Language Reference): ‘Normally not assigned. Use an empty string for appID.’ An empty string is passed by default.

  • conn_type: QBFC_CONST::CtUnknown, CtLocalQBD, CtRemoteQBD, CtLocalQBDLaunchUI, or CtRemoteQBOE. Default is QBFC_CONST::CtLocalQBD (1)

  • filename: The full path to the Quickbooks file; leave blank to connect to the currently open company file. Default is an empty string (Quickbooks should be running).

  • open_mode: The desired access mode. It can be one of three values:

    - QBFC_CONST::OmSingleUser (specifies single-user mode)
    - QBFC_CONST::OmMultiUser (specifies multi-user mode)
    - QBFC_CONST::OmDontCare (accept whatever mode is currently in effect, or single-user mode if no other mode is in effect)
    

    Default is QBFC_CONST::OmDontCare

If given a block, it yields the Session object and closes the Session and Connection when the block closes.

Otherwise, it returns the new Session object.



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/qbfc/session.rb', line 61

def open(*options, &block)
  qb = new(*options)
  if block_given?
    begin
      yield qb
    ensure
      qb.close
    end
  else
    qb
  end
end