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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81d2d0a434685e7b16bff8d0803c04baa84da393
4
- data.tar.gz: a5067a6f38c733b0dfa7462a23765f43358fa598
3
+ metadata.gz: 7c12c59830d8fe3c488630410560fcd8cfe27f50
4
+ data.tar.gz: 4a0ab18a8f0df82924f344b9cd89bf376a01722e
5
5
  SHA512:
6
- metadata.gz: aff98a001374ef10190b2a0aea55691838137facab69d94b9408f59db39d48c6030640a85a6e70b26343844d915fdfdc527e1c85a57e4a6f5ff870c41d705c2f
7
- data.tar.gz: 7e8c2cd42e38b26e2cf091bcda0ee0bc825fff4849ac5c185ccc17bc4173d82967bbe9ef9431f80736146c9016318e7b53d69bb9a9bc76f54815cb2f16e81691
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 ||= resource_class.find(@controller.params.fetch(:id))
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
- resource_class.all
54
+ @model.all
54
55
  elsif rights.any? { |r| r.permission_type == "on_ownerships" }
55
- resource_class.where("user_id = ? OR id IN (?)", @user.id, resource_ids)
56
+ @model.where("user_id = ? OR id IN (?)", @user.id, resource_ids)
56
57
  elsif rights.any? { |r| r.permission_type == "on_entry" }
57
- resource_class.where(id: resource_ids)
58
+ @model.where(id: resource_ids)
58
59
  else
59
- resource_class.none
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
- resource_class.model_name.element
93
+ @model.model_name.element
93
94
  end
94
95
 
95
96
  def controller_name(resource)
data/lib/adeia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Adeia
2
- VERSION = "0.11.4"
2
+ VERSION = "0.11.5"
3
3
  end
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
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 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails