effective_resources 2.18.4 → 2.18.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
  SHA256:
3
- metadata.gz: 6afb7b75d0b3a67f0522248e685bb8fb2fa973d6110e4ab5371c6579457eab1b
4
- data.tar.gz: 46b6e23e7fc14d623af21227175aa9c74fc4e5ace265b193e1522e293fa97946
3
+ metadata.gz: 15aae84ff3fea90339f7efe098d2866a9d2bc88b335b9655546106a08c4d1bed
4
+ data.tar.gz: 88309bf5bd6c7d80c17e879047646ab92ab49780db7e07e1df4bba525702226d
5
5
  SHA512:
6
- metadata.gz: 2daa3b7acc0596210380e8a6026e92691eb0a1a89591cb5c3aeda0601a740c7790630f2da1213fe31190948071b5319dad46bed18279603e6abbb48dc379153d
7
- data.tar.gz: ad76dbb446443fef1516bcfddbe9d35124157061eb41ed90d4520520b834c29ed670905f74cf4273c75d676707bfc014fd7b267e51fc68c772d501f9246e8ec9
6
+ metadata.gz: a632db851e6c74e33f4e7ff5daccc7990df2009a6f1fd18bce165e94a88bf14b31d5272c446b4e2dc8efbc09f2efc40aea2eab46a2ac5171bde47988c037db2b
7
+ data.tar.gz: 18b551721691c45be04f467855fd8c28f333c856fb0f30b3cc06615068ef84b6e16dad213a1cafbc10cc5836ba79f90e0a2728be50e2845022bceb7e6c16a457
@@ -13,7 +13,7 @@ module Effective
13
13
  end
14
14
 
15
15
  # called by effective_trash and effective_logging
16
- def instance_attributes(only: nil, except: nil)
16
+ def instance_attributes(only: nil, except: nil, associations: true)
17
17
  return {} unless instance.present?
18
18
 
19
19
  # Build up our only and except
@@ -34,43 +34,45 @@ module Effective
34
34
  attributes[association.name] = instance.send(association.name).to_s
35
35
  end
36
36
 
37
- # Grab the instance attributes of each nested resource
38
- nested_resources.each do |association|
39
- next if except.present? && except.include?(association.name)
40
- next unless only.blank? || only.include?(association.name)
37
+ if associations
38
+ # Grab the instance attributes of each nested resource
39
+ nested_resources.each do |association|
40
+ next if except.present? && except.include?(association.name)
41
+ next unless only.blank? || only.include?(association.name)
41
42
 
42
- next if association.options[:through]
43
+ next if association.options[:through]
43
44
 
44
- attributes[association.name] ||= {}
45
+ attributes[association.name] ||= {}
45
46
 
46
- Array(instance.send(association.name)).each_with_index do |child, index|
47
- next unless child.present?
47
+ Array(instance.send(association.name)).each_with_index do |child, index|
48
+ next unless child.present?
48
49
 
49
- resource = Effective::Resource.new(child)
50
- attributes[association.name][index] = resource.instance_attributes(only: only, except: except)
50
+ resource = Effective::Resource.new(child)
51
+ attributes[association.name][index] = resource.instance_attributes(only: only, except: except)
52
+ end
51
53
  end
52
- end
53
54
 
54
- (action_texts + has_ones).each do |association|
55
- next if except.present? && except.include?(association.name)
56
- next unless only.blank? || only.include?(association.name)
55
+ (action_texts + has_ones).each do |association|
56
+ next if except.present? && except.include?(association.name)
57
+ next unless only.blank? || only.include?(association.name)
57
58
 
58
- attributes[association.name] = instance.send(association.name).to_s
59
- end
59
+ attributes[association.name] = instance.send(association.name).to_s
60
+ end
60
61
 
61
- has_manys.each do |association|
62
- next if except.present? && except.include?(association.name)
63
- next unless only.blank? || only.include?(association.name)
62
+ has_manys.each do |association|
63
+ next if except.present? && except.include?(association.name)
64
+ next unless only.blank? || only.include?(association.name)
64
65
 
65
- next if BLACKLIST.include?(association.name)
66
- attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
67
- end
66
+ next if BLACKLIST.include?(association.name)
67
+ attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
68
+ end
68
69
 
69
- has_and_belongs_to_manys.each do |association|
70
- next if except.present? && except.include?(association.name)
71
- next unless only.blank? || only.include?(association.name)
70
+ has_and_belongs_to_manys.each do |association|
71
+ next if except.present? && except.include?(association.name)
72
+ next unless only.blank? || only.include?(association.name)
72
73
 
73
- attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
74
+ attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
75
+ end
74
76
  end
75
77
 
76
78
  attributes.delete_if { |_, value| value.blank? }
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.18.4'.freeze
2
+ VERSION = '2.18.5'.freeze
3
3
  end
@@ -18,8 +18,7 @@ module EffectiveResources
18
18
 
19
19
  # We use the newer syntax for serialize calls in rails 7.1 but it changes behaviour
20
20
  def self.serialize_with_coder?
21
- false
22
- #Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7')
21
+ Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7.1')
23
22
  end
24
23
 
25
24
  def self.authorized?(controller, action, resource)
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: 2.18.4
4
+ version: 2.18.5
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: 2023-11-29 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails