Sha256: e568d398321d110364d50a640bc60a31dc501d733bc5cb581072b376fcc4bb5c

Contents?: true

Size: 533 Bytes

Versions: 22

Compression:

Stored size: 533 Bytes

Contents

require 'reviewed/page'
require 'reviewed/product'
require 'reviewed/attachment'
require 'reviewed/deal'

module Reviewed
  class Article < Base
    has_attachments

    has_many :pages
    has_many :products
    has_many :deals
    has_many :related_articles, class_name: "Reviewed::Article"

    def find_page(slug)
      pages.find { |page| page.slug.match(/#{slug}/i) }
    end

    def primary_product
      if respond_to?(:products)
        products.select { |p| p.id == primary_product_id }.first
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
reviewed-1.2.4 lib/reviewed/article.rb
reviewed-1.2.3 lib/reviewed/article.rb
reviewed-1.3.0 lib/reviewed/article.rb
reviewed-1.2.2 lib/reviewed/article.rb
reviewed-1.2.0 lib/reviewed/article.rb
reviewed-1.1.0 lib/reviewed/article.rb
reviewed-1.0.4 lib/reviewed/article.rb
reviewed-1.0.3 lib/reviewed/article.rb
reviewed-1.0.2 lib/reviewed/article.rb
reviewed-1.0.1 lib/reviewed/article.rb
reviewed-1.0.0 lib/reviewed/article.rb
reviewed-0.9.1 lib/reviewed/article.rb
reviewed-0.9.0 lib/reviewed/article.rb
reviewed-0.8.0 lib/reviewed/article.rb
reviewed-0.7.1 lib/reviewed/article.rb
reviewed-0.7 lib/reviewed/article.rb
reviewed-0.6.4 lib/reviewed/article.rb
reviewed-0.6.3 lib/reviewed/article.rb
reviewed-0.6.2 lib/reviewed/article.rb
reviewed-0.6.1 lib/reviewed/article.rb