Sha256: f3250cc9ece0e504a6ee9d605ff8c661af5752e0d460a0afd1ae86956c0c307f

Contents?: true

Size: 897 Bytes

Versions: 9

Compression:

Stored size: 897 Bytes

Contents

class VirtualFeed
  attr_accessor :title
  attr_accessor :entries

  def finder_params=(hash)
    LOGGER.debug("setting finder params to #{hash.inspect}")
    @finder_params = hash
  end

  # This is to make the Virtual Feed walk like a duck
  def reload
    self
  end

  def finder_params
    # To prevent ActiveRecord from altering the hash when passed into #find
    @finder_params.clone
  end

  def entries
    LOGGER.debug("calling virtual feeds entries using finder_params #{finder_params.inspect}")
    entries = Entry.find(:all, finder_params)
    LOGGER.debug("found #{entries.size} entries using finder_params #{finder_params.inspect}")
    entries
  end

  def entry_count
    Entry.count(finder_params)
  end

  def last_updated
    if entries.empty?
      nil
    else
      entry = Entry.find(:first, finder_params)
      entry.date_published || entry.updated_at
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fastreader-1.0.1 lib/virtual_feed.rb
fastreader-1.0.0 lib/virtual_feed.rb
fastreader-1.0.3 lib/virtual_feed.rb
fastreader-1.0.4 lib/virtual_feed.rb
fastreader-1.0.5 lib/virtual_feed.rb
fastreader-1.0.2 lib/virtual_feed.rb
fastreader-1.0.7 lib/virtual_feed.rb
fastreader-1.0.6 lib/virtual_feed.rb
fastreader-1.0.8 lib/virtual_feed.rb