Skip to content

Instantly share code, notes, and snippets.

@mauricioklein
Created September 12, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricioklein/be5eaa6065823537070257ae8826b1e9 to your computer and use it in GitHub Desktop.
Save mauricioklein/be5eaa6065823537070257ae8826b1e9 to your computer and use it in GitHub Desktop.
Rom Repository relation
require 'equalizer'
require 'dry/data'
module Entities
class Friend < Dry::Data::Struct
include Equalizer.new(:id, :source_id, :target_id)
attribute :id, 'int'
attribute :source_id, 'int'
attribute :target_id, 'int'
end
end
module Persistence
module Relations
class Friends < ROM::Relation[:sql]
dataset :friend
register_as :friend
end
end
end
require 'equalizer'
require 'dry/data'
module Entities
class User < Dry::Data::Struct
include Equalizer.new(:id, :name)
attribute :id, 'int'
attribute :name, 'string'
end
end
module Persistence
module Relations
class Users < ROM::Relation[:sql]
dataset :user
register_as :user
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment