Sha256: 1e45f351e62f64e289d464d992ad4d4ad923ba29915a11f1e6d9b44126e66463

Contents?: true

Size: 501 Bytes

Versions: 4

Compression:

Stored size: 501 Bytes

Contents

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

4 entries across 4 versions & 1 rubygems

Version Path
lightspeed_restaurant-1.1.2 lib/lightspeed_restaurant/operations/list.rb
lightspeed_restaurant-1.1.1 lib/lightspeed_restaurant/operations/list.rb
lightspeed_restaurant-1.1.0 lib/lightspeed_restaurant/operations/list.rb
lightspeed_restaurant-1.0.0 lib/lightspeed_restaurant/operations/list.rb