Sha256: b04262e179821aa59aea45e3365600e2815d8eb5385aff314da1ffdf6f16ef8a

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module Troo
  module Remote
    module Persistence
      class List
        class << self
          def with(external_board_id, name)
            new(external_board_id, name).perform
          end
        end

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

        def perform
          create_local
        end

        private

        attr_reader :external_board_id, :name

        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_list,
            interpolation: {},
            query:         query,
            model:         Remote::List
          }
        end

        def query
          {
            name:     name,
            board_id: external_board_id
          }
        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/list.rb
troo-0.0.9 lib/troo/remote/persistence/list.rb