Module: ElsToken

Included in:
Runner
Defined in:
lib/els_token/module_inheritable_attributes.rb,
lib/els_token.rb,
lib/els_token/version.rb,
lib/els_token/els_identity.rb

Overview

Defined Under Namespace

Modules: ClassMethods, ModuleInheritableAttributes Classes: ElsIdentity, Runner

Constant Summary collapse

VERSION =
"1.2.4"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.authenticate(username, password, options) ⇒ Object

How about a few class methods of our own?



239
240
241
# File 'lib/els_token.rb', line 239

def self.authenticate(username,password,options)
  Runner.authenticate(username,password,options)
end

.get_identity(token, options) ⇒ Object



247
248
249
# File 'lib/els_token.rb', line 247

def self.get_identity(token, options)
  Runner.get_identity(token,options)
end

.included(base) ⇒ Object



8
9
10
11
12
13
# File 'lib/els_token.rb', line 8

def self.included(base)
  base.extend ClassMethods
  base.send :include, ElsToken::ModuleInheritableAttributes
  base.send :mattr_inheritable, :els_options
  base.instance_variable_set("@els_options", {})
end

.is_token_valid?(token, options) ⇒ Boolean

Returns:

  • (Boolean)


243
244
245
# File 'lib/els_token.rb', line 243

def self.is_token_valid?(token, options)
  Runner.is_token_valid?(token,options)
end

Instance Method Details

#authenticate(username, password) ⇒ Object



201
202
203
# File 'lib/els_token.rb', line 201

def authenticate(username,password)
  Runner.authenticate(username,password,self.class.els_options)
end

#get_identityObject



217
218
219
220
# File 'lib/els_token.rb', line 217

def get_identity
  token = cookies[self.class.els_options['cookie']]
  Runner.get_identity(token,self.class.els_options)
end

#get_raw_token_identity(token) ⇒ Object



213
214
215
# File 'lib/els_token.rb', line 213

def get_raw_token_identity(token)
  Runner.get_raw_token_identity(token,self.class.els_options)
end

#get_token_identity(token) ⇒ Object



209
210
211
# File 'lib/els_token.rb', line 209

def get_token_identity(token)
  Runner.get_token_identity(token,self.class.els_options)
end

extract the token from a cookie This method expects a hash called cookies to be present. It will look for a cookie with the key of the cookie value in the config hash

Returns:

  • (Boolean)


226
227
228
229
230
231
232
233
234
235
# File 'lib/els_token.rb', line 226

def is_cookie_token_valid?
  return true if self.class.els_options.has_key? 'faker'
  raise "No cookies instance found" if cookies.nil?
  token = cookies[self.class.els_options['cookie']]
  if token.nil? || !Runner.is_token_valid?(token,self.class.els_options)
    false
  else
    true
  end
end

#is_token_valid?(token) ⇒ Boolean

Returns:

  • (Boolean)


205
206
207
# File 'lib/els_token.rb', line 205

def is_token_valid?(token)
  Runner.is_token_valid?(token,self.class.els_options)
end