Sha256: aaf336d39fa760863e99a354811c6c259ddd143768b080278346dd9dd3bb15a8

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

module Enjoy::News
  module Models
    module Mongoid
      module News
        extend ActiveSupport::Concern

        include Enjoy::HtmlField

        included do
          field :name, type: String, localize: Enjoy::News.config.localize, default: ""

          field :time, type: Time
          index({enabled: 1, time: 1})

          enjoy_cms_html_field :excerpt, type: String, localize: Enjoy::News.configuration.localize, default: ""
          enjoy_cms_html_field :content, type: String, localize: Enjoy::News.configuration.localize, default: ""

          has_and_belongs_to_many :categories, class_name: "Enjoy::News::Category", inverse_of: nil

          scope :after_now, -> { where(:time.lt => Time.now) }
          scope :by_date, -> { desc(:time) }

          if Enjoy::News.config.gallery_support
            embeds_many :images, cascade_callbacks: true, class_name: "Enjoy::News::Image"
          end

        end

        def image_styles
          Enjoy::News.configuration.news_image_styles
        end

        def image_jcrop_options
          {}
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
enjoy_cms_news-0.4.0.2 lib/enjoy/news/models/mongoid/news.rb
enjoy_cms_news-0.4.0.1 lib/enjoy/news/models/mongoid/news.rb
enjoy_cms_news-0.4.0 lib/enjoy/news/models/mongoid/news.rb
enjoy_cms_news-0.4.0.beta3 lib/enjoy/news/models/mongoid/news.rb