Created
September 12, 2016 14:05
-
-
Save mauricioklein/be5eaa6065823537070257ae8826b1e9 to your computer and use it in GitHub Desktop.
Rom Repository relation
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
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 |
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
module Persistence | |
module Relations | |
class Friends < ROM::Relation[:sql] | |
dataset :friend | |
register_as :friend | |
end | |
end | |
end |
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
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 |
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
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