Sha256: 5f5f3517e3256c381e48cb384b8936422a9fd7eb86e8c6a2dfa0eb403dcb1854

Contents?: true

Size: 851 Bytes

Versions: 3

Compression:

Stored size: 851 Bytes

Contents

module Troo
  class CreateCard
    class << self
      def for(list, name = nil, description = nil)
        new(list, name, description).perform
      end
    end

    def initialize(list, name = nil, description = nil)
      @list        = list
      @name        = name
      @description = description
    end

    def perform
      update_cards
    end

    private
    attr_reader :list, :name, :description

    def update_cards
      return CardPersistence.for(create_card) if create_card
      false
    end

    def create_card
      @card ||= Trello::Card.create(attributes)
    rescue Trello::InvalidAccessToken
      raise Troo::InvalidAccessToken
    rescue Trello::Error
      false
    end

    def attributes
      {
        name:    name,
        list_id: list.external_list_id,
        desc:    description
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.7 lib/troo/actions/create_card.rb
troo-0.0.6 lib/troo/actions/create_card.rb
troo-0.0.5 lib/troo/actions/create_card.rb