Sha256: ee95b03137036fc8dd2f549b28c44648c8d2f279d063c32beab4cecc1c2863e5

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module YeshuaCrm
  module Liquid
    class IssuesDrop < ::Liquid::Drop
      def initialize(issues)
        @issues = issues
      end

      def before_method(id)
        issue = @issues.where(:id => id).first || Issue.new
        IssueDrop.new issue
      end

      def all
        @all ||= @issues.map do |issue|
          IssueDrop.new issue
        end
      end

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

      def size
        @issues.size
      end
    end

    class IssueDrop < ::Liquid::Drop
      include ActionView::Helpers::UrlHelper

      delegate :id,
               :subject,
               :description,
               :visible?,
               :open?,
               :start_date,
               :due_date,
               :overdue?,
               :completed_percent,
               :updated_on,
               :created_on,
               :to => :@issue

      def initialize(issue)
        @issue = issue
      end

      def link
        link_to @issue.subject, self.url
      end

      def url
        Rails.application.routes.url_helpers.issue_path(@issue)
      end

      def author
        @user ||= UserDrop.new(@issue.author)
      end

      def custom_field_values
        @issue.custom_field_values
      end      

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yeshua_crm-1.0.1 lib/yeshua_crm/liquid/drops/issues_drop.rb
yeshua_crm-1.0.0 lib/yeshua_crm/liquid/drops/issues_drop.rb