phi_attrs 0.4.1 → 0.4.3

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
  SHA256:
3
- metadata.gz: e9491994c4490412fc98cf81f0962715528ddfebeb262d4bc262f5724d5523fc
4
- data.tar.gz: 88695a4f672da5e95513e6507f51fba9f8fa8d76d2bc90baef9cbdd251fcebe5
3
+ metadata.gz: '05083f79f5cdcfc67ab415d129d37d84f287612a1669cc966d0ec065b60df474'
4
+ data.tar.gz: 89256e8ca7a9f67738a49d119a3b7ce9d3bd364d295f4562fa2cb9a11617553c
5
5
  SHA512:
6
- metadata.gz: ba47d32c99dfa8b757f9d37da114113d6099fd0db989ef4515f354105880f524300983795022b424fd10e19aa3fc0bd95c5317865ec2d53c180f6d16fbd597fe
7
- data.tar.gz: 01054a9b3dafc8a1547681fdcc9990b1b7adf7fa6eb454dfab1a98f39752ed9477138f32161db2b5fd464f2b85c4e7470d57961a7306b5e5fb5f415f09ec6f45
6
+ metadata.gz: caaaba36bc35c442ac349e6131cec84c5603e7c27a8dd3f28d436a47a39225f016721d3b38a75ed4cb426154afb97a7040de69e3622141e59190056f939d429d
7
+ data.tar.gz: e4be1b87f3129b9abaf7200f300cf3f3e10034f61d476348503798cff8545b82bee455c3c26e76894e12bfbda2d99a2ee17df65e065b7251a71a99f2e2c5c390
@@ -526,7 +526,7 @@ module PhiAttrs
526
526
  raise PhiAttrs::Exceptions::PhiAccessException, 'PHI Access required, please call allow_phi or allow_phi! first' unless phi_allowed?
527
527
  end
528
528
 
529
- def reload
529
+ def reload(options = nil)
530
530
  @__phi_relations_extended.clear
531
531
  super
532
532
  end
@@ -703,12 +703,15 @@ module PhiAttrs
703
703
  self.class.send(:define_method, wrapped_method) do |*args, **kwargs, &block|
704
704
  relation = send(unwrapped_method, *args, **kwargs, &block)
705
705
 
706
- if phi_allowed? && relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)
706
+ access_context = phi_context
707
+ if access_context&.phi_access_allowed && relation.present? && relation_klass(relation).included_modules.include?(PhiRecord)
707
708
  relations = relation.is_a?(Enumerable) ? relation : [relation]
708
709
  relations.each do |r|
709
- r.allow_phi!(phi_allowed_by, phi_access_reason) unless @__phi_relations_extended.include?(r)
710
+ next if @__phi_relations_extended.include?(r) && r.phi_allowed?
711
+
712
+ r.allow_phi!(access_context.user_id, access_context.reason)
713
+ @__phi_relations_extended.add(r)
710
714
  end
711
- @__phi_relations_extended.merge(relations)
712
715
  self.class.__instances_with_extended_phi.add(self)
713
716
  end
714
717
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PhiAttrs
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phi_attrs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Kirby