ROM
@ilavriv
What is ROM?
Ruby object mapper, toolkit for data manipulation
- Powerful
- Small
- Easy
- No magic
- Usable
- Fast
Benefits to using ROM
- Repositories
- Relations
- Commands
- Mappers
- Adapters
ROM elements
ROM Design

Using: Setup
ROM.setup(
default: [:sql, 'sqlite::memory'],
other: [:csv, '/path/to/files', {
encoding: 'utf-8',
col_sep: ';'
}]
)Using: Relations
class BooksRelation < ROM::Relation[:sql]
include ROM::SQL::Plugin::Pagination
dataset :books
per_page 30
def ordered
order(:id)
end
endUsing: Commands
class CreateBook < ROM::Commands::Create[:sql]
relation :users
register_as :create
endUsing: Mappers
class UserAsEntity < ROM::Mapper
register_as :entity
relation :users
model User
endUsing: Repositories
class BookRepository < ROM::Repository::Base
relations :book
def new_books(timestamp)
users.listing.added_after(timestamp)
end
endAdapters
-
rom -sql -
rom -mongo - rom-csv
- ...
3
links
Any questions?
Rom rb
By Ivan Lavriv
Rom rb
- 609