From 1ce894870c82a2d856745f86f6e11a0ef6c72cc1 Mon Sep 17 00:00:00 2001 From: Don Morrison Date: Sun, 26 Feb 2017 23:19:06 -0800 Subject: [PATCH] Update `Relation` to subclass `Memory::Relation` Recent changes to `ROM::Memory::Relation` made it possible to use it as the superclass for adapter relations. This adds schema support among other things. --- lib/rom/csv/relation.rb | 6 ++---- spec/integration/gateway_spec.rb | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/rom/csv/relation.rb b/lib/rom/csv/relation.rb index 8871e86..d02cd6d 100644 --- a/lib/rom/csv/relation.rb +++ b/lib/rom/csv/relation.rb @@ -1,4 +1,4 @@ -require 'rom/relation' +require 'rom/memory' module ROM module CSV @@ -9,11 +9,9 @@ module CSV # end # # @api public - class Relation < ROM::Relation + class Relation < ROM::Memory::Relation adapter :csv - forward :join, :project, :restrict, :order - def count dataset.count end diff --git a/spec/integration/gateway_spec.rb b/spec/integration/gateway_spec.rb index e4a80ba..8b2e87f 100644 --- a/spec/integration/gateway_spec.rb +++ b/spec/integration/gateway_spec.rb @@ -9,6 +9,12 @@ configuration.relation(:users) do gateway :users + schema(:users) do + attribute :user_id, Types::Strict::Int + attribute :name, Types::Strict::String + attribute :email, Types::Strict::String + end + def by_name(name) restrict(name: name) end