lib/active_recall/models/deck.rb in active_recall-1.6.4 vs lib/active_recall/models/deck.rb in active_recall-1.8.0

- old
+ new

@@ -2,13 +2,13 @@ module ActiveRecall class Deck < ActiveRecord::Base include Enumerable include ActiveRecall::Base - self.table_name = 'active_recall_decks' + self.table_name = "active_recall_decks" belongs_to :user, polymorphic: true - has_many :items, class_name: 'ActiveRecall::Item', dependent: :destroy + has_many :items, class_name: "ActiveRecall::Item", dependent: :destroy def each _items.each do |item| if block_given? yield item @@ -25,11 +25,11 @@ def _items source_class.find(items.pluck(:source_id)) end def <<(source) - raise ArgumentError, 'Word already in the stack' if include?(source) + raise ArgumentError, "Word already in the stack" if include?(source) items << ActiveRecall::Item.new(deck: self, source_id: source.id, source_type: source.class.name) end def self.add_deck(user) @@ -41,35 +41,35 @@ .find_by(deck: self, source_id: source.id, source_type: source.class.name) .destroy end def review - _review.map(&:source) + source_class.where(id: _review.select(:source_id)) end def next _review.first.try(:source) end def last - items.order('created_at desc').limit(1).first.try(:source) + items.order("created_at desc").limit(1).first.try(:source) end def untested - source_class.find(items.untested.pluck(:source_id)) + source_class.where(id: items.untested.select(:source_id)) end def failed - source_class.find(items.failed.pluck(:source_id)) + source_class.where(id: items.failed.select(:source_id)) end def known - source_class.find(items.known.pluck(:source_id)) + source_class.where(id: items.known.select(:source_id)) end def expired - source_class.find(items.expired.pluck(:source_id)) + source_class.where(id: items.expired.select(:source_id)) end def box(number) source_class.find(items.where(box: number).pluck(:source_id)) end @@ -87,13 +87,13 @@ .or(items.expired) .order(random_order_function) end def random_order_function - Arel.sql(mysql? ? 'RAND()' : 'random()') + Arel.sql(mysql? ? "RAND()" : "random()") end def mysql? - source_class.connection.adapter_name == 'Mysql2' + source_class.connection.adapter_name == "Mysql2" end end end