Skip to content

Instantly share code, notes, and snippets.

@zhum
Created March 21, 2018 08:03
Show Gist options
  • Save zhum/0cc9ef9fbb787ae70dbcfb1bb155cdad to your computer and use it in GitHub Desktop.
Save zhum/0cc9ef9fbb787ae70dbcfb1bb155cdad to your computer and use it in GitHub Desktop.
rom test for dynamic class
source 'https://rubygems.org'
gem 'rom'
gem 'rom-sql'
gem 'rom-yaml', '2.0.0.rc2'
gem 'sqlite3'
#!/usr/bin/env ruby
require "sqlite3"
require 'rom-sql'
require 'rom-yaml'
class MyTest < ROM::Relation[:yaml]
schema do
attribute :id, ROM::Types::Int
primary_key :id
end
end
puts "Static test..."
rom1=ROM.container(:yaml, 'test1.yml') do |config|
config.register_relation(MyTest)
end
puts "Passed."
puts "Dynamic test..."
rom2=ROM.container(:yaml, 'test1.yml') do |config|
my_klass=Class.new(ROM::Relation[:yaml]) do
schema do
attribute :id, ROM::Types::Int
primary_key :id
end
end
config.register_relation(my_klass)
end
puts "Passed."
my_test:
- id: 1
text: qwe
- id: 2
text: asd
- id: 3
text: zxc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment