effective_resources 2.18.3 → 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: ea57d3f23e61f43abd4e0ff00964090ad1bfb395c5373d8b00fe6c0eddf6cd90
4
- data.tar.gz: 18ff0a66af3512a12ab8feb4742aea894b5be29a84347990c1d1fb8d9a31324f
3
+ metadata.gz: 15aae84ff3fea90339f7efe098d2866a9d2bc88b335b9655546106a08c4d1bed
4
+ data.tar.gz: 88309bf5bd6c7d80c17e879047646ab92ab49780db7e07e1df4bba525702226d
5
5
  SHA512:
6
- metadata.gz: 33196e45ae8c5505267223ab4d16cc90204c70360df828d4edbc26dca946bb1ff3b49e2ec4bc234118f7bed95aeecf34ef13ea4f2296e80f134b07012a51c583
7
- data.tar.gz: cbbc3a05bbb0e78cd0c1039a80b8c55855918945c8e3d2e2fb9d697ab62e3342d45b140d33aa4f672ef8aa1445748c56a8c70d618c073853814f971ddd5428c1
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.3'.freeze
2
+ VERSION = '2.18.5'.freeze
3
3
  end
@@ -16,9 +16,9 @@ module EffectiveResources
16
16
 
17
17
  include EffectiveGem
18
18
 
19
- # We use the newer syntax for serialize calls in rails 7+
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
- 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')
22
22
  end
23
23
 
24
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.3
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