Class: Casablanca::Ticket

Inherits:
Object
  • Object
show all
Defined in:
lib/casablanca/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ticket, service_url, renew = false) ⇒ Ticket

Returns a new instance of Ticket.



169
170
171
172
173
# File 'lib/casablanca/client.rb', line 169

def initialize(ticket, service_url, renew = false)      
  @service_url = service_url
  @ticket  = ticket
  @renew = renew
end

Instance Attribute Details

#body=(value) ⇒ Object (writeonly)

Sets the attribute body

Parameters:

  • value

    the value to set the attribute body to.



168
169
170
# File 'lib/casablanca/client.rb', line 168

def body=(value)
  @body = value
end

#failure_codeObject

Returns the value of attribute failure_code.



166
167
168
# File 'lib/casablanca/client.rb', line 166

def failure_code
  @failure_code
end

#failure_messageObject

Returns the value of attribute failure_message.



166
167
168
# File 'lib/casablanca/client.rb', line 166

def failure_message
  @failure_message
end

#service_urlObject (readonly)

Returns the value of attribute service_url.



167
168
169
# File 'lib/casablanca/client.rb', line 167

def service_url
  @service_url
end

#ticketObject (readonly)

Returns the value of attribute ticket.



167
168
169
# File 'lib/casablanca/client.rb', line 167

def ticket
  @ticket
end

#userObject

Returns the value of attribute user.



166
167
168
# File 'lib/casablanca/client.rb', line 166

def user
  @user
end

Class Method Details

.from_hash(hash) ⇒ Object

Create a Ticket from a Hash. Useful for unserializing



177
178
179
180
181
# File 'lib/casablanca/client.rb', line 177

def self.from_hash(hash)
  ticket = Ticket.new(hash[:ticket], hash[:service_url])
  ticket.user = hash[:user]
  ticket
end

Instance Method Details

#authenticateObject



207
208
209
210
# File 'lib/casablanca/client.rb', line 207

def authenticate
  response = CasResponseParser.parse(self, @body)
  authenticated?
end

#authenticated?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/casablanca/client.rb', line 203

def authenticated?
  !!@user
end

#to_hashObject

Convert a Ticket to a Hash. Useful for serializing



185
186
187
188
189
190
191
# File 'lib/casablanca/client.rb', line 185

def to_hash
  props = {}
  props[:user] = @user if authenticated?
  props[:service_url] = @service_url
  props[:ticket] = @ticket
  props
end

#to_request_paramsObject

Convert the ticket to a Hash for a request



195
196
197
198
199
200
201
# File 'lib/casablanca/client.rb', line 195

def to_request_params
  params = {}
  params[:service] = @service_url
  params[:ticket] = @ticket if @ticket
  params[:renew] = 'true' if @renew      
  params
end