Sha256: 03ba5eb78d5dd36818055cef641270ed57b22edd312d726529962d6e301e8eec

Contents?: true

Size: 714 Bytes

Versions: 3

Compression:

Stored size: 714 Bytes

Contents

module Troo
  class CreateList
    class << self
      def for(board, name)
        new(board, name).perform
      end
    end

    def initialize(board, name)
      @board = board
      @name  = name
    end

    def perform
      update_lists
    end

    private
    attr_reader :board, :name

    def update_lists
      return Troo::ListPersistence.for(create_list) if create_list
      false
    end

    def create_list
      @list ||= Trello::List.create(attributes)
    rescue Trello::InvalidAccessToken
      raise Troo::InvalidAccessToken
    rescue Trello::Error
      false
    end

    def attributes
      {
        name:     name,
        board_id: board.external_board_id
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.4 lib/troo/actions/create_list.rb
troo-0.0.3 lib/troo/actions/create_list.rb
troo-0.0.2 lib/troo/actions/create_list.rb