From 700a4c521505e9afbe8ddfd455d254beeaeb3d69 Mon Sep 17 00:00:00 2001 From: Mauricio Giacomini Girardello <mauriciogiacomini4@gmail.com> Date: Tue, 3 Nov 2015 08:10:39 -0200 Subject: [PATCH] adding collections contexts --- app/models/collections/context.rb | 5 +++++ app/models/collections/public_context.rb | 11 +++++++++++ app/models/collections/user_context.rb | 8 ++++++++ app/models/collections/user_private_context.rb | 10 ++++++++++ app/models/collections/user_public_context.rb | 10 ++++++++++ 5 files changed, 44 insertions(+) create mode 100644 app/models/collections/context.rb create mode 100644 app/models/collections/public_context.rb create mode 100644 app/models/collections/user_context.rb create mode 100644 app/models/collections/user_private_context.rb create mode 100644 app/models/collections/user_public_context.rb diff --git a/app/models/collections/context.rb b/app/models/collections/context.rb new file mode 100644 index 00000000..647b7996 --- /dev/null +++ b/app/models/collections/context.rb @@ -0,0 +1,5 @@ +module Collections + class Context + attr_reader :from, :privacy + end +end diff --git a/app/models/collections/public_context.rb b/app/models/collections/public_context.rb new file mode 100644 index 00000000..ad3a7f8a --- /dev/null +++ b/app/models/collections/public_context.rb @@ -0,0 +1,11 @@ +## +# This class represents an specification for listing collections +# The PublicContext class specify all collections with field privacy=public +class Collections::PublicContext < Collections::Context + + def initialize + @from = 'Collection' + @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 new file mode 100644 index 00000000..5a6d9b1a --- /dev/null +++ b/app/models/collections/user_context.rb @@ -0,0 +1,8 @@ +class UserContext < Collections::Context + + def initialize(user) + @user = user + @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 new file mode 100644 index 00000000..fb60d7df --- /dev/null +++ b/app/models/collections/user_private_context.rb @@ -0,0 +1,10 @@ +## +# This class represents an specification for listing collections +# The PublicContext class specify all collections with field privacy=public +class Collections::UserPrivateContext < Collections::UserContext + + def initialize + @privacy = '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 new file mode 100644 index 00000000..c5bb5d52 --- /dev/null +++ b/app/models/collections/user_public_context.rb @@ -0,0 +1,10 @@ +## +# This class represents an specification for listing collections +# The PublicContext class specify all collections with field privacy=public +class Collections::UserPublicContext < Collections::UserContext + + def initialize + @privacy = 'public' + end + +end \ No newline at end of file -- GitLab