Class: ClickSecuritiesPluginSession
- Inherits:
-
Object
- Object
- ClickSecuritiesPluginSession
show all
- Defined in:
- lib/jiji_plugin.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ClickSecuritiesPluginSession.
94
95
96
97
98
99
|
# File 'lib/jiji_plugin.rb', line 94
def initialize( props, logger, demo=false )
@props = props
@logger = logger
@m = Mutex.new
@demo = demo
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/jiji_plugin.rb', line 100
def method_missing( name, *args )
@m.synchronize {
begin
session.send( name, *args )
rescue
close
raise $!
end
}
end
|
Instance Method Details
#close ⇒ Object
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/jiji_plugin.rb', line 111
def close
begin
@session.logout if @session
rescue
@logger.error $!
ensure
@session = nil
@client = nil
end
end
|
#session ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/jiji_plugin.rb', line 121
def session
begin
proxy = nil
if @props.key?(:proxy) && @props[:proxy] != nil && @props[:proxy].length > 0
proxy = @props[:proxy]
end
@client ||= ClickClientScrap::Client.new( proxy, @demo )
@session ||= @client.fx_session( @props[:user], @props[:password] )
rescue
@logger.error $!
raise $!
end
@session
end
|