Sha256: 807034831e6a90b6ee8cae9828ab24f63644625db37f743a2434ee33801601a8

Contents?: true

Size: 532 Bytes

Versions: 1

Compression:

Stored size: 532 Bytes

Contents

# frozen_string_literal: true

module LightspeedRestaurantClient
  module Operations
    module List
      def list(params = {})
        response = JSON.parse(LightspeedRestaurantClient.get(resource_path, {}, params))
        results = response.is_a?(Array) ? response : response['results']
        instantiate(results)
      end
      alias all list

      private

      def instantiate(records)
        records.map do |record|
          is_a?(Class) ? new(record) : self.class.new(record)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lightspeed_restaurant-2.0.0 lib/lightspeed_restaurant/operations/list.rb