Sha256: d30feee40efda735700cf9009394f2e12d7d8d3668700761d6896d65ddf09bb0

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Troo
  module Remote
    module Persistence
      class List
        class << self
          # @param  [String]
          # @param  [String]
          # @return []
          def with(external_board_id, name)
            new(external_board_id, name).perform
          end
        end

        # @param  [String]
        # @param  [String]
        # @return []
        def initialize(external_board_id, name)
          @external_board_id = external_board_id
          @name              = name
        end

        # @return []
        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

1 entries across 1 versions & 1 rubygems

Version Path
troo-0.0.11 lib/troo/remote/persistence/list.rb