Sha256: 440854bf83bbf99c41b5fe3eb830660c40fc0fc3599e5945edb31016ab6e118c

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

module Troo
  module Commands
    module Refresh
      class All
        def self.dispatch
          new.refresh_all
        end

        def refresh_all
          'All local data refreshed.' if refreshed?
        end

        private

        def refreshed?
          external_board_ids.map do |external_board_id|
            External::List.fetch(external_board_id)
            External::Member.fetch(external_board_id)
            External::Card.fetch(external_board_id).map do |card|
              External::Comment.fetch(card.external_card_id,
                                      mode: :card)
            end
          end
          true
        end

        def external_board_ids
          active_boards.map(&:external_board_id)
        end

        def active_boards
          all_boards.delete_if { |b| b.nil? || b.closed == true }
        end

        def all_boards
          @boards ||= External::Board.fetch(0,  mode: :all)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 lib/troo/commands/refresh/all.rb