Class: Wowza::REST::Publisher
- Inherits:
-
Object
- Object
- Wowza::REST::Publisher
show all
- Includes:
- Assignment::Attributes, WillChange
- Defined in:
- lib/wowza/rest/publisher.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from WillChange
#changed, #changed?, #changed_attributes, #changes, included, #restore_attributes
Constructor Details
#initialize(attributes = {}) ⇒ Publisher
Returns a new instance of Publisher.
11
12
13
14
15
16
|
# File 'lib/wowza/rest/publisher.rb', line 11
def initialize(attributes={})
assign_attributes(attributes) if attributes
super()
self.persisted = false
changes_applied
end
|
Instance Attribute Details
#conn ⇒ Object
Returns the value of attribute conn.
8
9
10
|
# File 'lib/wowza/rest/publisher.rb', line 8
def conn
@conn
end
|
#name ⇒ Object
Returns the value of attribute name.
8
9
10
|
# File 'lib/wowza/rest/publisher.rb', line 8
def name
@name
end
|
#password ⇒ Object
Returns the value of attribute password.
8
9
10
|
# File 'lib/wowza/rest/publisher.rb', line 8
def password
@password
end
|
#persisted ⇒ Object
Returns the value of attribute persisted.
8
9
10
|
# File 'lib/wowza/rest/publisher.rb', line 8
def persisted
@persisted
end
|
#server_name ⇒ Object
Returns the value of attribute server_name.
8
9
10
|
# File 'lib/wowza/rest/publisher.rb', line 8
def server_name
@server_name
end
|
Instance Method Details
#attributes ⇒ Object
18
19
20
21
22
23
|
# File 'lib/wowza/rest/publisher.rb', line 18
def attributes
{
name: name,
password: password,
}
end
|
#destroy ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/wowza/rest/publisher.rb', line 79
def destroy
if persisted?
resp = conn.delete resource_path
if resp.code == "204"
self.persisted = false
clear_changes_information
end
end
end
|
#id ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/wowza/rest/publisher.rb', line 29
def id
if changes[:name].nil?
name
else
changes[:name].first
end
end
|
#persisted? ⇒ Boolean
54
55
56
|
# File 'lib/wowza/rest/publisher.rb', line 54
def persisted?
persisted
end
|
#reload! ⇒ Object
68
69
70
71
72
73
|
# File 'lib/wowza/rest/publisher.rb', line 68
def reload!
resp = conn.get resource_path
attributes = JSON.parse(resp.body)
assign_attributes(attributes) if attributes
clear_changes_information
end
|
#rollback! ⇒ Object
75
76
77
|
# File 'lib/wowza/rest/publisher.rb', line 75
def rollback!
restore_attributes
end
|
#save ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/wowza/rest/publisher.rb', line 37
def save
resp = conn.send(persist_method, persist_path) do |req|
req.body = to_json
end
if resp.code == "201" || resp.code == "200"
self.persisted = true
end
changes_applied
end
|
#to_json ⇒ Object
25
26
27
|
# File 'lib/wowza/rest/publisher.rb', line 25
def to_json
attributes.to_json
end
|