Class: OnSIP::Session

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Defined in:
lib/onsip/session.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

create, process_create_session_response, process_destroy_session_response

Constructor Details

#initialize(attributes = {}) ⇒ Session

Returns a new instance of Session.



6
7
8
# File 'lib/onsip/session.rb', line 6

def initialize(attributes = {})
  @attributes = Hashie::Mash.new attributes
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



4
5
6
# File 'lib/onsip/session.rb', line 4

def attributes
  @attributes
end

Instance Method Details

#accountObject



26
27
28
# File 'lib/onsip/session.rb', line 26

def 
  @account ||= self.user.
end

#destroy!Object



30
31
32
33
34
# File 'lib/onsip/session.rb', line 30

def destroy!
  session = self.class.destroy!(self.id)
  self.attributes.merge!(session.attributes)
  self
end

#established?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/onsip/session.rb', line 18

def established?
  @attributes.IsEstablished && @attributes.IsEstablished.downcase == 'true'
end

#idObject



10
11
12
# File 'lib/onsip/session.rb', line 10

def id
  @attributes.SessionId
end

#userObject



22
23
24
# File 'lib/onsip/session.rb', line 22

def user
  @user ||= User.read(self.user_id)
end

#user_idObject



14
15
16
# File 'lib/onsip/session.rb', line 14

def user_id
  @attributes.UserId
end