From 655985dd4fe42d95163a8435ead9a8db75af07e7 Mon Sep 17 00:00:00 2001 From: Mauricio Giacomini Girardello <mauriciogiacomini4@gmail.com> Date: Tue, 3 Nov 2015 09:13:44 -0200 Subject: [PATCH] change methods call from contexts --- app/models/collections/context.rb | 10 ++++++---- app/models/collections/public_context.rb | 9 ++++++--- app/models/collections/user_context.rb | 5 ++++- app/models/collections/user_private_context.rb | 2 +- app/models/collections/user_public_context.rb | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/models/collections/context.rb b/app/models/collections/context.rb index c4bd7258..5413ff64 100644 --- a/app/models/collections/context.rb +++ b/app/models/collections/context.rb @@ -1,10 +1,12 @@ module Collections class Context - attr_reader :from, :privacy - def initialize - @from = nil - @privacy = nil + def from + raise NotImplementedError, 'This method must be implemented' + end + + def privacy + raise NotImplementedError, 'This method must be implemented' end end diff --git a/app/models/collections/public_context.rb b/app/models/collections/public_context.rb index ad3a7f8a..d7013b13 100644 --- a/app/models/collections/public_context.rb +++ b/app/models/collections/public_context.rb @@ -3,9 +3,12 @@ # The PublicContext class specify all collections with field privacy=public class Collections::PublicContext < Collections::Context - def initialize - @from = 'Collection' - @privacy = 'public' + def from + 'Collection' + end + + def privacy + 'public' end end \ No newline at end of file diff --git a/app/models/collections/user_context.rb b/app/models/collections/user_context.rb index 5a6d9b1a..5c70f92c 100644 --- a/app/models/collections/user_context.rb +++ b/app/models/collections/user_context.rb @@ -2,7 +2,10 @@ class UserContext < Collections::Context def initialize(user) @user = user - @from = sprintf "select expand(in('BelongsTo')) from %s)", user.rid + end + + def from + sprintf "select expand(in('BelongsTo')) from %s)", @user.rid end end \ No newline at end of file diff --git a/app/models/collections/user_private_context.rb b/app/models/collections/user_private_context.rb index 4cc68174..3b6b8534 100644 --- a/app/models/collections/user_private_context.rb +++ b/app/models/collections/user_private_context.rb @@ -4,7 +4,7 @@ class Collections::UserPrivateContext < Collections::UserContext def privacy - @privacy = 'private' + 'private' end end \ No newline at end of file diff --git a/app/models/collections/user_public_context.rb b/app/models/collections/user_public_context.rb index 743875c9..f1612eb0 100644 --- a/app/models/collections/user_public_context.rb +++ b/app/models/collections/user_public_context.rb @@ -4,7 +4,7 @@ class Collections::UserPublicContext < Collections::UserContext def privacy - @privacy = 'public' + 'public' end end \ No newline at end of file -- GitLab