Class: Rubix::MediaType
- Inherits:
-
Model
- Object
- Model
- Rubix::MediaType
show all
- Defined in:
- lib/rubix/models/media_type.rb
Constant Summary
collapse
- TYPE_CODES =
The numeric codes corresponding to each media type.
The default will be ‘script’.
{
:email => 0,
:script => 1,
:sms => 2,
:jabber => 3,
:ez_texting => 100
}.freeze
- TYPE_NAMES =
TYPE_CODES.invert.freeze
Instance Attribute Summary collapse
Attributes inherited from Model
#id, #properties
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
all, all_params, all_request, #before_destroy, #before_update, #create, #create_request, #destroy, #destroy_params, #destroy_request, each, find, find_or_create, find_request, get_params, id_field, #id_field, list, #new_record?, request, #request, #resource_name, resource_name, #save, #update, #update_params, #update_request, #validate, web_request, zabbix_name
Methods included from Logs
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(properties = {}) ⇒ MediaType
Returns a new instance of MediaType.
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/rubix/models/media_type.rb', line 28
def initialize properties={}
super(properties)
self.description = properties[:description]
self.type = properties[:type]
self.server = properties[:server]
self.helo = properties[:helo]
self.email = properties[:email]
self.path = properties[:path]
self.modem = properties[:modem]
self.username = properties[:username]
self.password = properties[:password]
end
|
Instance Attribute Details
#description ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def description
@description
end
|
#email ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def email
@email
end
|
#helo ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def helo
@helo
end
|
#modem ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def modem
@modem
end
|
#password ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def password
@password
end
|
#path ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def path
@path
end
|
#server ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def server
@server
end
|
#type ⇒ Object
24
25
26
|
# File 'lib/rubix/models/media_type.rb', line 24
def type
@type ||= :script
end
|
#username ⇒ Object
21
22
23
|
# File 'lib/rubix/models/media_type.rb', line 21
def username
@username
end
|
Class Method Details
.build(media_type) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/rubix/models/media_type.rb', line 70
def self.build media_type
new({
:id => media_type[id_field].to_i,
:type => self::TYPE_NAMES[media_type['type'].to_i],
:description => media_type['description'],
:server => media_type['smtp_server'],
:helo => media_type['smtp_helo'],
:email => media_type['smtp_email'],
:path => media_type['exec_path'],
:modem => media_type['gsm_modem'],
:username => media_type['username'],
:password => media_type['passwd']
})
end
|
.find_params(options = {}) ⇒ Object
66
67
68
|
# File 'lib/rubix/models/media_type.rb', line 66
def self.find_params options={}
get_params.merge(:filter => {id_field => options[:id], :description => options[:description]})
end
|
Instance Method Details
#create_params ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/rubix/models/media_type.rb', line 45
def create_params
{
:description => description,
:type => TYPE_CODES[type]
}.tap do |p|
case type
when :email
p[:smtp_server] = server if server
p[:smtp_helo] = helo if helo
p[:smtp_email] = email if email
when :script
p[:exec_path] = path if path
when :sms
p[:gsm_modem] = modem if modem
when :jabber
p[:username] = username if username
p[:passwd] = password if password
end
end
end
|