Created
March 21, 2018 08:03
-
-
Save zhum/0cc9ef9fbb787ae70dbcfb1bb155cdad to your computer and use it in GitHub Desktop.
rom test for dynamic class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rom' | |
gem 'rom-sql' | |
gem 'rom-yaml', '2.0.0.rc2' | |
gem 'sqlite3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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