Simple Car Repository

A minimal in-memory Ruby repository for SimpleCar entities.

What it provides

  • Seeded in-memory store with 5 sample cars
  • CRUD-style operations: add, add_range, get, get_all, update, delete
  • Validation for nil cars and blank IDs

Requirements

  • Ruby 3.1+
  • Gem dependency: sdn_test_simple_car

Import

require "grft_test_simple_car_repository"

or, when loading directly from the repository:

require_relative "lib/in_memory_simple_car_repository"

Quick Start

require "grft_test_simple_car_repository"

repo = InMemorySimpleCarRepository.new
car = SimpleCar.new("BMW", "M3", 2023)
repo.add(car)

all_cars = repo.get_all
puts "Total cars: #{all_cars.length}"

API Reference

  • InMemorySimpleCarRepository.new
  • add(car)
  • add_range(cars)
  • get(id) -> SimpleCar | nil
  • get_all -> Array<SimpleCar>
  • update(car) -> true/false
  • delete(id) -> true/false