Class: OpenStack::Keystone::Public::Auth::Token

Inherits:
Base show all
Defined in:
lib/open_stack/keystone/public/auth.rb

Overview

Authentication Token

Instance Method Summary collapse

Methods inherited from Base

headers

Methods inherited from ActiveResource::Base

#load

Constructor Details

#initialize(attributes = {}, persisted = false) ⇒ Token

:notnew:



136
137
138
139
140
141
142
143
144
# File 'lib/open_stack/keystone/public/auth.rb', line 136

def initialize(attributes = {}, persisted = false) # :notnew:
  attributes = attributes.with_indifferent_access
  new_attributes = {
      :id => attributes[:id],
      :expires => attributes[:expires]
  }

  super(new_attributes, persisted)
end

Instance Method Details

#expired?Boolean

True if the token is expired

Returns:

  • (Boolean)


152
153
154
# File 'lib/open_stack/keystone/public/auth.rb', line 152

def expired?
  DateTime.strptime(attributes[:expires], OpenStack::DATETIME_FORMAT) < DateTime.now.utc
end

#expires_atObject

Expiration date and time for this token



147
148
149
# File 'lib/open_stack/keystone/public/auth.rb', line 147

def expires_at
  DateTime.strptime(attributes[:expires], OpenStack::DATETIME_FORMAT)
end