Class: Yt::Models::Resource
- Inherits:
-
Base
- Object
- Base
- Yt::Models::Resource
show all
- Defined in:
- lib/yt/models/resource.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#has_report
#has_viewer_percentages
#has_one
#has_many
#has_authentication
Constructor Details
#initialize(options = {}) ⇒ Resource
Returns a new instance of Resource.
19
20
21
22
23
24
25
|
# File 'lib/yt/models/resource.rb', line 19
def initialize(options = {})
@url = URL.new(options[:url]) if options[:url]
@id = options[:id] || (@url.id if @url)
@auth = options[:auth]
@snippet = Snippet.new(data: options[:snippet]) if options[:snippet]
@status = Status.new(data: options[:status]) if options[:status]
end
|
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
9
10
11
|
# File 'lib/yt/models/resource.rb', line 9
def auth
@auth
end
|
Instance Method Details
#kind ⇒ Object
27
28
29
|
# File 'lib/yt/models/resource.rb', line 27
def kind
@url ? @url.kind.to_s : self.class.to_s.demodulize.underscore
end
|
#update(attributes = {}) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/yt/models/resource.rb', line 35
def update(attributes = {})
underscore_keys! attributes
body = build_update_body attributes
params = {part: body.keys.join(',')}
do_update params: params, body: body.merge(id: @id) do |data|
@id = data['id']
@snippet = Snippet.new data: data['snippet'] if data['snippet']
@status = Status.new data: data['status'] if data['status']
true
end
end
|
#username ⇒ Object
31
32
33
|
# File 'lib/yt/models/resource.rb', line 31
def username
@url.username if @url
end
|