Class ArsModels::Context
In: lib/ars_models/context.rb
Parent: Base

Ruby wrapper class for the java com.kd.ars.models.datasource.ArsContext object. Instances of Context represent a single AR server user.

Methods

login   new  

Attributes

ars_context  [R]  Store the internal java representation of the context
authentication  [RW]  Authentication string for the AR server user context.
password  [RW]  Password for the AR server user context.
port  [RW]  Ar Server connection port associated with the AR server user context.
prognum  [RW]  RPC program number of the server. Specify 390600 to use the admin queue, a number from 390621 to 390634 or 390636 to 390669 or 390680-390694 to use a private queue, or 0 (default) to use the fast or list server queue. This parameter is overridden by the ARRPC environment variable.
server  [RW]  Server ip or dns name associated with the AR server user context.
username  [RW]  Username for the AR server user context.

Public Class methods

Creates a new Context object. This can be used to generate a Context manually or to build a Context from a JAPI ArsContext object. server and username are required attributes.

Manual Generation:

Valid Options: +:username+, +:password+, +:server+, +:port+, +:authentication+, +:prognum+

  context = Context.new(:username => 'Demo', :password => '', :server => '127.0.0.1', :authentication => 'MyDomain', :port => 5000, :prognum => 390636 )

JAPI Build:

  field = Context.new(new com.kd.ars.models.structure.ArsContext('Demo', '', '127.0.0.1', 'MyDomain', 5000, 390636))

[Source]

    # File lib/ars_models/context.rb, line 37
37:     def initialize(*args)
38:       # Call the ArsModels::Base initializer and delegate to the build or generate method

39:       super(*args)
40:     end

Public Instance methods

Attempt to log in the AR server user context represented by the Context object. This method returns an array of hashes representing any AR server messages triggered during log in. These method hashes include values for the following keys: +:message+, +:type+, +:number+. If any problems were encountered during login a new ModelException is thrown.

[Source]

     # File lib/ars_models/context.rb, line 94
 94:     def login
 95:       begin
 96:         # Try to log in

 97:         @ars_context.login
 98:         # If the login was successful, capture any AR messages

 99:         @ars_context.get_messages.collect do |message|
100:           {:message => message.get_message, :type => message.get_type, :number => message.get_number}
101:         end
102:       rescue NativeException => exception
103:         # If an exception is thrown, raise a ModelException

104:         raise Exceptions::ModelException.new(exception.cause)
105:       end
106:     end

[Validate]