Sha256: d37c32e856facbfef8859fef48561cd9cd9aa5eb4be3e04be57d3b72ff326ea5

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Troo
  module External
    class Board < Resource
      class << self
        def fetch(external_id, options = {})
          new(external_id, options).fetch_by_external_id.map do |resource|
            Troo::BoardPersistence.for(resource) unless closed?(resource)
          end
        end

        def fetch_all
          new.fetch_all.map do |resource|
            Troo::BoardPersistence.for(resource) unless closed?(resource)
          end
        end
      end

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

      def fetch_by_external_id
        [Trello::Board.find(external_id)]
      rescue Trello::InvalidAccessToken
        raise Troo::InvalidAccessToken
      rescue Trello::Error
        []
      end

      def fetch_all
        Trello::Board.all
      rescue Trello::InvalidAccessToken
        raise Troo::InvalidAccessToken
      rescue Trello::Error
        []
      end

      private
      attr_reader :external_id
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.4 lib/troo/external/board.rb