phi_attrs 0.4.1 → 0.4.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
  SHA256:
3
- metadata.gz: e9491994c4490412fc98cf81f0962715528ddfebeb262d4bc262f5724d5523fc
4
- data.tar.gz: 88695a4f672da5e95513e6507f51fba9f8fa8d76d2bc90baef9cbdd251fcebe5
3
+ metadata.gz: 28560c0910d408f722f837687ac660a43aa3e708c10366603490270a9bfa3aaf
4
+ data.tar.gz: 9c58fa96bbff3aecf4d7f63defd5bbdba40e72ddea6073dc3f02337b4b9a4b36
5
5
  SHA512:
6
- metadata.gz: ba47d32c99dfa8b757f9d37da114113d6099fd0db989ef4515f354105880f524300983795022b424fd10e19aa3fc0bd95c5317865ec2d53c180f6d16fbd597fe
7
- data.tar.gz: 01054a9b3dafc8a1547681fdcc9990b1b7adf7fa6eb454dfab1a98f39752ed9477138f32161db2b5fd464f2b85c4e7470d57961a7306b5e5fb5f415f09ec6f45
6
+ metadata.gz: 639da1bdf5990baacfd20d427690c2ff7fb4445461ab150aafea3f2b9e611074fc1e6dd3a32198e50de18a5002095e818c38a3deec50c3ac3f75560ad3fe831f
7
+ data.tar.gz: 0b1efe76204b467c5ea51c48d5df7153e7cf63df3fa89530e2d331d8f9e9b5813673f0feb01443d90ea67bae87eee47ff267e7b319588588f619782e087858ac
@@ -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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wyatt Kirby