Class: Elastix::Extension

Inherits:
Base
  • Object
show all
Defined in:
lib/elastix/extension.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

close_db_connection, establish_connection, establish_db_connection, establish_web_connection, reload, web_connected?

Constructor Details

#initialize(params) ⇒ Extension

Returns a new instance of Extension.



5
6
7
# File 'lib/elastix/extension.rb', line 5

def initialize params
  params.each_pair{|key,value| instance_variable_set "@#{key}", value}
end

Instance Attribute Details

#devinfo_secretObject

Returns the value of attribute devinfo_secret.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def devinfo_secret
  @devinfo_secret
end

#extensionObject

Returns the value of attribute extension.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def extension
  @extension
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def name
  @name
end

#outboundcidObject

Returns the value of attribute outboundcid.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def outboundcid
  @outboundcid
end

#record_inObject

Returns the value of attribute record_in.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def record_in
  @record_in
end

#record_outObject

Returns the value of attribute record_out.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def record_out
  @record_out
end

#sipnameObject

Returns the value of attribute sipname.



3
4
5
# File 'lib/elastix/extension.rb', line 3

def sipname
  @sipname
end

Class Method Details

.allObject



48
49
50
51
52
# File 'lib/elastix/extension.rb', line 48

def self.all
  Sip.uniq.pluck(:id).map do |extension|
    get_extension_object(extension) if exist?(extension)
  end
end

.create(params) ⇒ Object



42
43
44
45
46
# File 'lib/elastix/extension.rb', line 42

def self.create params
  e = Extension.new(params)
  e.save
  e
end

.find(extension) ⇒ Object



38
39
40
# File 'lib/elastix/extension.rb', line 38

def self.find extension
 get_extension_object(extension) if exist?(extension)
end

Instance Method Details

#==(extension) ⇒ Object



29
30
31
# File 'lib/elastix/extension.rb', line 29

def == extension
  self.to_hash == extension.to_hash
end

#destroyObject



9
10
11
12
# File 'lib/elastix/extension.rb', line 9

def destroy
  @@elastix.get("#{@@base_address}/config.php?type=setup&display=extensions&extdisplay=#{self.extension}&action=del")
  Base.reload
end

#saveObject



14
15
16
17
18
19
20
21
# File 'lib/elastix/extension.rb', line 14

def save
  if Extension.exist? extension
    update_extension_object
  else
    new_extension_object
  end
  Base.reload
end

#to_hashObject



33
34
35
# File 'lib/elastix/extension.rb', line 33

def to_hash
  Hash[self.instance_variables.map{|var| [var.to_s.delete("@"), self.instance_variable_get(var)]}]
end

#update_attributes(params) ⇒ Object



23
24
25
26
27
# File 'lib/elastix/extension.rb', line 23

def update_attributes params
  params.each_pair{|key,value| instance_variable_set "@#{key}", value}
  update_extension_object
  Base.reload
end