class RubyPocket::FavoriteQuery

Public Class Methods

new(scope = nil) click to toggle source
# File lib/ruby_pocket/favorite_query.rb, line 15
def initialize(scope = nil)
  @scope = scope || Favorite
end
where(options) click to toggle source
# File lib/ruby_pocket/favorite_query.rb, line 9
def self.where(options)
  new.where(options)
end

Public Instance Methods

where(options) click to toggle source
# File lib/ruby_pocket/favorite_query.rb, line 19
def where(options)
  if options[:tag_names]
    tags = find_all_tags(options[:tag_names])
    @scope = where_tags(tags)
  end

  self
end

Private Instance Methods

where_tags(tags) click to toggle source
# File lib/ruby_pocket/favorite_query.rb, line 30
def where_tags(tags)
  tags.reduce(@scope) do |scope, tag|
    scope.where(tag)
  end
end