Class: Wowza::REST::Publishers
- Inherits:
-
Object
- Object
- Wowza::REST::Publishers
- Defined in:
- lib/wowza/rest/publishers.rb
Instance Attribute Summary collapse
-
#server_name ⇒ Object
Returns the value of attribute server_name.
Instance Method Summary collapse
- #all ⇒ Object
- #find(name) ⇒ Object
-
#initialize(conn) ⇒ Publishers
constructor
A new instance of Publishers.
- #resource_path ⇒ Object
- #server_path ⇒ Object
Constructor Details
#initialize(conn) ⇒ Publishers
Returns a new instance of Publishers.
7 8 9 |
# File 'lib/wowza/rest/publishers.rb', line 7 def initialize(conn) @conn = conn end |
Instance Attribute Details
#server_name ⇒ Object
Returns the value of attribute server_name.
5 6 7 |
# File 'lib/wowza/rest/publishers.rb', line 5 def server_name @server_name end |
Instance Method Details
#all ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/wowza/rest/publishers.rb', line 11 def all resp = conn.get(resource_path) JSON.parse(resp.body)['publishers'].map do |attrs| Publisher.new(name: attrs["name"]).tap do |p| p.conn = conn p.persisted = true end end end |
#find(name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wowza/rest/publishers.rb', line 21 def find(name) resp = conn.get("#{resource_path}/#{name}") if resp.code == "200" attrs = JSON.parse(resp.body) Publisher.new(name: attrs["name"]).tap do |p| p.conn = conn p.persisted = true end else nil end end |
#resource_path ⇒ Object
34 35 36 |
# File 'lib/wowza/rest/publishers.rb', line 34 def resource_path "#{server_path}/publishers" end |
#server_path ⇒ Object
42 43 44 |
# File 'lib/wowza/rest/publishers.rb', line 42 def server_path "/v2/servers/#{server_name}" end |