Sha256: 3011327eb77b1897afa5adeaadd850e4e5c8539f516afa5600605c83e6450709

Contents?: true

Size: 994 Bytes

Versions: 4

Compression:

Stored size: 994 Bytes

Contents

module Redmineup
  module Liquid
    class NewssDrop < ::Liquid::Drop

      def self.default_drop
        self.new News.visible.order("#{News.table_name}.created_on")
      end

      def initialize(newss)
        @newss = newss
      end

      def before_method(id)
        news = @newss.where(:id => id).first || News.new
        NewsDrop.new news
      end

      def last
        NewsDrop.new News.last
      end

      def all
        @all ||= @newss.map do |news|
          NewsDrop.new news
        end
      end

      def each(&block)
        all.each(&block)
      end

      def size
        @newss.size
      end
    end

    class NewsDrop < ::Liquid::Drop
      delegate :id, :title, :summary, :description, :visible?, :commentable?, :to => :@news

      def initialize(news)
        @news = news
      end

      def author
        UserDrop.new @news.author
      end

      def custom_field_values
        @news.custom_field_values
      end   
            
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redmineup-1.0.5 lib/redmineup/liquid/drops/news_drop.rb
redmineup-1.0.4 lib/redmineup/liquid/drops/news_drop.rb
redmineup-1.0.3 lib/redmineup/liquid/drops/news_drop.rb
redmineup-1.0.2 lib/redmineup/liquid/drops/news_drop.rb