Module: Yt::Associations::Ratings
- Defined in:
- lib/yt/associations/ratings.rb
Overview
Provides the ‘has_one :rating` method to YouTube resources, which allows to invoke rating-related methods, such as .like. YouTube resources with rating are: videos.
Instance Method Summary collapse
Instance Method Details
#dislike ⇒ Object
22 23 24 25 |
# File 'lib/yt/associations/ratings.rb', line 22 def dislike .update :dislike !liked? end |
#like ⇒ Object
17 18 19 20 |
# File 'lib/yt/associations/ratings.rb', line 17 def like .update :like liked? end |
#liked? ⇒ Boolean
13 14 15 |
# File 'lib/yt/associations/ratings.rb', line 13 def liked? . == :like end |
#rating ⇒ Object
9 10 11 |
# File 'lib/yt/associations/ratings.rb', line 9 def @rating ||= .first end |
#unlike ⇒ Object
27 28 29 30 |
# File 'lib/yt/associations/ratings.rb', line 27 def unlike .update :none !liked? end |