Sha256: 898a3edc2f4b0d2a628714114e54ce51088a6d43c178938d2c769e60bf4eca20

Contents?: true

Size: 428 Bytes

Versions: 3

Compression:

Stored size: 428 Bytes

Contents

module LightspeedRestaurant
  module Operations
    module List
      def list(params = {})
        response = JSON.parse(LightspeedRestaurant.get(resource_path, {}, params))
        instantiate(response['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

3 entries across 3 versions & 1 rubygems

Version Path
lightspeed_restaurant-0.2.0 lib/lightspeed_restaurant/operations/list.rb
lightspeed_restaurant-0.1.5 lib/lightspeed_restaurant/operations/list.rb
lightspeed_restaurant-0.1.4 lib/lightspeed_restaurant/operations/list.rb