Sha256: c917755c625585e2b15e43132576c912bd90027011b90d84ecfd58a9d890f0d7

Contents?: true

Size: 866 Bytes

Versions: 1

Compression:

Stored size: 866 Bytes

Contents

module Troo
  module External
    class Resource
      attr_reader :external_id

      class << self
        def fetch(external_id, options = {})
          new(external_id, options).persist
        end
      end

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

      def fetch
        case options.fetch(:mode)
        when :all    then all_boards
        when :board  then by_board_id
        when :list   then by_list_id
        when :card   then by_card_id
        when :member then by_member_id
        end
      rescue Trello::InvalidAccessToken
        raise Troo::InvalidAccessToken
      rescue Trello::Error
        []
      end

      private

      def options
        defaults.merge!(@options)
      end

      def defaults
        { mode: :board }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 lib/troo/external/resource.rb