effective_resources 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c677c888d40faa747d421ffbeecbf1452e5328db
4
- data.tar.gz: 2bf38b93293b53d35a86f1e9c551b1cfec07489f
3
+ metadata.gz: ab07e09ae92fa3b5b45c6aaea043524311cf55ee
4
+ data.tar.gz: a1932eebb584d966fc283bde64a4ccef8da30fc2
5
5
  SHA512:
6
- metadata.gz: ab530180ab92b4e5a866b34d38941d0234e73564c4291b02b661f675eb399d4bbd5fcf4445b6db935734da154a36f1a120255fe05839fcc7b814d92784a61cf2
7
- data.tar.gz: dd14ce62821ee55c08ded91a33fca6a57a17ecf3a857d9aad138b7586b8590a0304252f652dc7ebb519799836dc3c100699e9b640bf42b014e74d7a45c11aa9e
6
+ metadata.gz: fa2a85a3c35493d374fbd6ecc681edb1e33db170adc18e3b9839d2d5968c6f2b47cfa9fa862798d9e8b92e68b17da2a24c27b1aa8bdf2785851e3a1621a3102e
7
+ data.tar.gz: 035d29dfab61fd4de301630257e82f5022cc31bc57515065e17303eb703b1a000c524806961c189ee9265d29a6d6611f4fdc6932f4b35e8f6c930922936cdf5b
@@ -48,7 +48,7 @@ module EffectiveResourcesPrivateHelper
48
48
 
49
49
  # Replace resource name in any token strings
50
50
  if opts['data-confirm']
51
- opts['data-confirm'].gsub!('@resource', (resource.to_s.presence || effective_resource.human_name))
51
+ opts['data-confirm'].gsub!('@resource', (resource.to_s.presence || effective_resource.human_name).to_s)
52
52
  end
53
53
 
54
54
  opts.except(:default, :only, :except, :if, :unless, :redirect, :success, :danger)
@@ -9,8 +9,8 @@ module Effective
9
9
  @instance || klass.new
10
10
  end
11
11
 
12
- # called by effective_trash as defaults, and effective_logging sometimes with true or false
13
- def instance_attributes(include_associated: true)
12
+ # called by effective_trash and effective_logging
13
+ def instance_attributes(include_associated: true, include_nested: true)
14
14
  return {} unless instance.present?
15
15
 
16
16
  attributes = { attributes: instance.attributes }
@@ -20,16 +20,22 @@ module Effective
20
20
  belong_tos.each do |association|
21
21
  attributes[association.name] = instance.send(association.name).to_s
22
22
  end
23
+ end
23
24
 
25
+ if include_associated || include_nested
24
26
  nested_resources.each do |association|
25
27
  attributes[association.name] ||= {}
26
28
 
29
+ next if association.options[:through]
30
+
27
31
  Array(instance.send(association.name)).each_with_index do |child, index|
28
32
  resource = Effective::Resource.new(child)
29
- attributes[association.name][index] = resource.instance_attributes
33
+ attributes[association.name][index] = resource.instance_attributes(include_associated: include_associated, include_nested: include_nested)
30
34
  end
31
35
  end
36
+ end
32
37
 
38
+ if include_associated
33
39
  has_ones.each do |association|
34
40
  attributes[association.name] = instance.send(association.name).to_s
35
41
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
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.1
4
+ version: 1.0.2
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-09-15 00:00:00.000000000 Z
11
+ date: 2018-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails