Sha256: 0d9c705230c33f4efb1bc4bcf059da2bf5492d8480289433015b47996fe60b06

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module Troo
  module Remote
    module Persistence
      class Board
        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
          return Troo::Persistence::Local
            .with_collection(resource).first if any?
          false
        end

        def any?
          resource.any?
        end

        def resource
          @resource ||= API::Client.perform(parameters)
        end

        def parameters
          {
            verb:          :post,
            endpoint:      :create_board,
            interpolation: {},
            query:         query,
            model:         Remote::Board
          }
        end

        def query
          {
            name: name,
            desc: description
          }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
troo-0.0.10 lib/troo/remote/persistence/board.rb
troo-0.0.9 lib/troo/remote/persistence/board.rb