Sha256: dd4d2cff06c368c8ba294e9d4f6d59059c62b78e65bdb17dbc71efd62a6aae74

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Tr3llo
  module Command
    module Card
      class AssignCommand
        def initialize(card_id, board_id)
          @card_id = card_id
          @board_id = board_id
        end

        def execute
          interface.print_frame do
            user_id = prompt_for_user_id!(@board_id)
            assign_card(user_id)
            interface.puts("Card has been assigned.")
          end
        end

        private

        attr_reader :user_id, :card_id

        def assign_card(user_id)
          card = API::Card.find(card_id)
          members = card[:idMembers] << user_id
          API::Card.assign_members(card_id, members)
        end

        def prompt_for_user_id!(board_id)
          board_id = $container.resolve(:board)[:id]
          users = Tr3llo::API::User.find_all_by_board(board_id)

          @user_id =
            Tr3llo::Presenter::Card::AssignPresenter
            .new(interface)
            .prompt_for_user_id(users)
        end

        def interface
          $container.resolve(:interface)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
3llo-0.3.1 lib/3llo/commands/card/assign.rb
3llo-0.3.0 lib/3llo/commands/card/assign.rb
3llo-0.2.0 lib/3llo/commands/card/assign.rb
3llo-0.1.12 lib/3llo/commands/card/assign.rb