Class: Wowza::REST::Publisher

Inherits:
Object
  • Object
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

#connObject

Returns the value of attribute conn.



8
9
10
# File 'lib/wowza/rest/publisher.rb', line 8

def conn
  @conn
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/wowza/rest/publisher.rb', line 8

def name
  @name
end

#passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/wowza/rest/publisher.rb', line 8

def password
  @password
end

#persistedObject

Returns the value of attribute persisted.



8
9
10
# File 'lib/wowza/rest/publisher.rb', line 8

def persisted
  @persisted
end

#server_nameObject

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

#attributesObject



18
19
20
21
22
23
# File 'lib/wowza/rest/publisher.rb', line 18

def attributes
  {
    name: name,
    password: password,
  }
end

#destroyObject



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

#idObject



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

Returns:

  • (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

#saveObject



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_jsonObject



25
26
27
# File 'lib/wowza/rest/publisher.rb', line 25

def to_json
  attributes.to_json
end