Module: Yt::Associations::HasReports

Included in:
Models::Base
Defined in:
lib/yt/associations/has_reports.rb

Overview

Provides methods to access the analytics reports of a resource.

YouTube resources with reports are: channels and videos.

Instance Method Summary collapse

Instance Method Details

#has_report(metric) ⇒ Object

Defines two public instance methods to access the reports of a resource for a specific metric.

Examples:

Adds earnings and earnings_on on a Channel resource.

class Channel < Resource
  has_report :earnings
end

Parameters:

  • metric (Symbol)

    the metric to access the reports of.



27
28
29
30
31
32
33
34
# File 'lib/yt/associations/has_reports.rb', line 27

def has_report(metric)
  require 'yt/collections/reports'

  define_metric_on_method metric
  define_metric_method metric
  define_range_metric_method metric
  define_all_metric_method metric
end