Skip to content

Instantly share code, notes, and snippets.

@solnic
Created May 7, 2015 13:49
Show Gist options
  • Save solnic/5017fa6adb70668e6dfe to your computer and use it in GitHub Desktop.
Save solnic/5017fa6adb70668e6dfe to your computer and use it in GitHub Desktop.
Manual ROM env setup
require "rom/memory"
memory_repo = ROM::Memory::Repository.new
user_dataset = memory_repo.dataset(:users)
class Users < ROM::Relation[:memory]
end
class UserMapper < ROM::Mapper
model name: 'UserEntity' # ROM supports generating model classes
attribute :name
end
user_relation = Users.new(user_dataset)
user_mapper = UserMapper.build # using build injects default mapper processor
user_relation.insert(name: 'Jane')
puts user_mapper.call(user_relation).to_a.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment