adeia 0.11.4 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adeia/controller_resource.rb +7 -6
- data/lib/adeia/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c12c59830d8fe3c488630410560fcd8cfe27f50
|
4
|
+
data.tar.gz: 4a0ab18a8f0df82924f344b9cd89bf376a01722e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 740b5861b98ab7cd216618892599680f498e8cbc5e3697889280723178fe699863b7c297ee6d541a762b246e21e9de0c75c8e73418150e947ef7d7c29ef58e87
|
7
|
+
data.tar.gz: 6859f560bca9a3bec5642a0819c990c12ae3030680766b3e4affcab659c10d7eee156eb668d7691cd023fabc56d955b089ee9126a75ba7075ad614b3c20c75e5
|
@@ -32,6 +32,7 @@ module Adeia
|
|
32
32
|
@controller_name = args.fetch(:controller, @controller.controller_path)
|
33
33
|
@token = args.fetch(:token, @controller.request.GET[:token])
|
34
34
|
@resource = args[:resource]
|
35
|
+
@model = args.fetch(:model, resource_class)
|
35
36
|
@user = @controller.current_user
|
36
37
|
@controller.current_user ||= GuestUser.new # if not signed in but authorized
|
37
38
|
@controller.store_location
|
@@ -39,7 +40,7 @@ module Adeia
|
|
39
40
|
|
40
41
|
def load_resource
|
41
42
|
begin
|
42
|
-
@resource ||=
|
43
|
+
@resource ||= @model.find(@controller.params.fetch(:id))
|
43
44
|
@controller.instance_variable_set("@#{resource_name}", @resource)
|
44
45
|
rescue KeyError
|
45
46
|
raise MissingParams.new(:id)
|
@@ -50,13 +51,13 @@ module Adeia
|
|
50
51
|
rights = authorization.read_rights.merge(authorization.token_rights(:read)) { |key, v1, v2| v1 + v2 }
|
51
52
|
rights, resource_ids = rights[:rights], rights[:resource_ids]
|
52
53
|
@records ||= if rights.any? { |r| r.permission_type == "all_entries" }
|
53
|
-
|
54
|
+
@model.all
|
54
55
|
elsif rights.any? { |r| r.permission_type == "on_ownerships" }
|
55
|
-
|
56
|
+
@model.where("user_id = ? OR id IN (?)", @user.id, resource_ids)
|
56
57
|
elsif rights.any? { |r| r.permission_type == "on_entry" }
|
57
|
-
|
58
|
+
@model.where(id: resource_ids)
|
58
59
|
else
|
59
|
-
|
60
|
+
@model.none
|
60
61
|
end
|
61
62
|
@controller.instance_variable_set("@#{resource_name.pluralize}", @records)
|
62
63
|
end
|
@@ -89,7 +90,7 @@ module Adeia
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def resource_name
|
92
|
-
|
93
|
+
@model.model_name.element
|
93
94
|
end
|
94
95
|
|
95
96
|
def controller_name(resource)
|
data/lib/adeia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adeia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khcr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|