Sha256: 4cbd171b7f339697113277de493e1e0f012673faffdbb1ecb328f02209897fb9

Contents?: true

Size: 534 Bytes

Versions: 7

Compression:

Stored size: 534 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

7 entries across 7 versions & 1 rubygems

Version Path
reviewed-0.4.6 lib/reviewed/article.rb
reviewed-0.4.5 lib/reviewed/article.rb
reviewed-0.4.4 lib/reviewed/article.rb
reviewed-0.4.3 lib/reviewed/article.rb
reviewed-0.4.2 lib/reviewed/article.rb
reviewed-0.4.1 lib/reviewed/article.rb
reviewed-0.4.0 lib/reviewed/article.rb