Sha256: efa972c5bf2c4e2e02f53c90deaf65694ad67bca5ca7d8b0f0738e0314a8bc0d
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
require 'reviewed/page' require 'reviewed/product' require 'reviewed/attachment' require 'reviewed/deal' module Reviewed class Article < Base has_many :pages has_many :products has_many :attachments 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 def attachments(tag=nil) if tag.present? @attributes.attachments.select do |attachment| attachment_tags = attachment.tags || [] attachment_tags.map(&:downcase).include?(tag.downcase) end else @attributes.attachments end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
reviewed-0.2.2 | lib/reviewed/article.rb |