effective_resources 1.0.2 → 1.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41ccd958aa2d034e20655b10bfe8a830bf162dad
|
4
|
+
data.tar.gz: d56e278ea8440a596378c2e5f943c32cc5a4c1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2bd71876feb1b9437d2d2026f44e69f3aa93ff3a17a1b2c9e22b3c9c794a7128531321787e4fc6b5f3061bacb89e1186de8f2852dea56a47628da31dde44499
|
7
|
+
data.tar.gz: 74dc40f978cb4af876f258a5c1acd32c2865c65b030a8516b40d620a4981ce6544016bb75e40833059ba82f9c6212c7ba8baf12f8bbce6268ccb465ef0d3d6a3
|
@@ -269,7 +269,7 @@ module Effective
|
|
269
269
|
self.resources ||= resource_scope.where(id: params[:ids])
|
270
270
|
end
|
271
271
|
|
272
|
-
if effective_resource.scope?(action)
|
272
|
+
if request.get? && effective_resource.scope?(action)
|
273
273
|
self.resources ||= resource_scope.public_send(action)
|
274
274
|
end
|
275
275
|
|
@@ -50,7 +50,17 @@ module Effective
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
permitted_params = permitted_params.map
|
53
|
+
permitted_params = permitted_params.map do |k, (datatype, v)|
|
54
|
+
if datatype == :array
|
55
|
+
{ k => [] }
|
56
|
+
elsif datatype == :permitted_param && k.to_s.ends_with?('_ids')
|
57
|
+
{ k => [] }
|
58
|
+
elsif datatype == :effective_address
|
59
|
+
{ k => EffectiveAddresses.permitted_params }
|
60
|
+
else
|
61
|
+
k
|
62
|
+
end
|
63
|
+
end
|
54
64
|
|
55
65
|
# Recursively add any accepts_nested_resources
|
56
66
|
effective_resource.nested_resources.each do |nested|
|
@@ -18,6 +18,11 @@ module Effective
|
|
18
18
|
belong_tos.inject({}) do |h, ass|
|
19
19
|
unless ass.foreign_key == 'site_id' && ass.respond_to?(:acts_as_site_specific)
|
20
20
|
h[ass.foreign_key.to_sym] = [:integer, :index => true]
|
21
|
+
|
22
|
+
if ass.options[:polymorphic]
|
23
|
+
h[ass.foreign_type.to_sym] = [:integer, :index => true]
|
24
|
+
end
|
25
|
+
|
21
26
|
end; h
|
22
27
|
end
|
23
28
|
end
|
@@ -26,6 +31,15 @@ module Effective
|
|
26
31
|
has_manys_ids.inject({}) { |h, ass| h[ass] = [:array]; h }
|
27
32
|
end
|
28
33
|
|
34
|
+
def has_ones_attributes
|
35
|
+
has_ones_ids.inject({}) { |h, ass| h[ass] = [:array]; h }
|
36
|
+
end
|
37
|
+
|
38
|
+
def effective_addresses_attributes
|
39
|
+
return {} unless instance.respond_to?(:effective_address_names)
|
40
|
+
instance.effective_address_names.inject({}) { |h, name| h[name] = [:effective_address]; h }
|
41
|
+
end
|
42
|
+
|
29
43
|
# All will include primary_key, created_at, updated_at and belongs_tos
|
30
44
|
# This is the attributes as defined by the effective_resources do .. end block
|
31
45
|
# { :name => [:string, { permitted: false }], ... }
|
@@ -33,7 +47,12 @@ module Effective
|
|
33
47
|
atts = (model ? model.attributes : {})
|
34
48
|
|
35
49
|
if all # Probably being called by permitted_attributes
|
36
|
-
primary_key_attribute
|
50
|
+
primary_key_attribute
|
51
|
+
.merge(belong_tos_attributes)
|
52
|
+
.merge(has_manys_attributes)
|
53
|
+
.merge(has_ones_attributes)
|
54
|
+
.merge(effective_addresses_attributes)
|
55
|
+
.merge(atts)
|
37
56
|
else # This is the migrator. This should match table_attributes
|
38
57
|
belong_tos_attributes.merge(atts.reject { |_, v| v[0] == :permitted_param })
|
39
58
|
end
|
@@ -46,7 +65,8 @@ module Effective
|
|
46
65
|
|
47
66
|
(attributes.keys - [klass.primary_key]).inject({}) do |h, name|
|
48
67
|
if klass.respond_to?(:column_for_attribute) # Rails 4+
|
49
|
-
|
68
|
+
column = klass.column_for_attribute(name)
|
69
|
+
h[name.to_sym] = [column.type] if column.table_name # Rails 5 attributes API
|
50
70
|
else
|
51
71
|
h[name.to_sym] = [klass.columns_hash[name].type]
|
52
72
|
end; h
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|