Sha256: 95371f5cecc86704796cecf718e8266db76294b96463f535c66b797b8c78b1f0

Contents?: true

Size: 822 Bytes

Versions: 1

Compression:

Stored size: 822 Bytes

Contents

module Troo
  class CreateBoard
    class << self
      def with(name, description = nil)
        new(name, description).perform
      end
    end

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

    def perform
      create_local
    end

    private

    attr_reader :name, :description

    def create_local
      if create_remote
        Persistence::Board.for(create_remote)
        # refresh for lists
      else
        false
      end
    end

    def create_remote
      @board ||= Trello::Board.create(attributes)
    rescue Trello::InvalidAccessToken
      raise Troo::InvalidAccessToken
    rescue Trello::Error
      false
    end

    def attributes
      {
        name:        name,
        description: description
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.8 lib/troo/actions/create_board.rb