Sha256: e5354d8da93f9fcaeac0e2c557fa4c1069337571f05faacc95010198fc6c0db6

Contents?: true

Size: 857 Bytes

Versions: 3

Compression:

Stored size: 857 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 Troo::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.4 lib/troo/actions/create_card.rb
troo-0.0.3 lib/troo/actions/create_card.rb
troo-0.0.2 lib/troo/actions/create_card.rb