Sha256: 7c3c66d565651dd39c21e86439eaea4cfd069a54157f875ca30e08a50d727831

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Troo
  module External
    class Card < Resource
      class << self
        def fetch(external_id, options = {})
          new(external_id, options).fetch_by_external_id.map do |resource|
            unless closed?(resource)
              Troo::External::Comment.fetch(resource.id, { mode: :card }) if options.fetch(:comments, true)
              CardPersistence.for(resource)
            end
          end
        end
      end

      def initialize(external_id, options = {})
        @external_id = external_id
        @options     = options
      end

      private
      attr_reader :external_id

      def options
        defaults.merge!(@options)
      end

      def defaults
        { comments: true, mode: :board }
      end

      def by_board_id
        Trello::Board.find(external_id).cards
      end

      def by_list_id
        Trello::List.find(external_id).cards
      end

      def by_card_id
        [Trello::Card.find(external_id)]
      end

      def by_member_id
        []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/external/card.rb
troo-0.0.6 lib/troo/external/card.rb
troo-0.0.5 lib/troo/external/card.rb