sequel-privacy 0.2.0 → 0.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: 62f27f7d396ed16fefe728a75cd9de079eb55cc1e37c4fb7c56a3e444bf5724c
4
- data.tar.gz: 4ac98ed1bbbe88e4fac544fbfb70e7c080914106b765ca00a7d32f85188a516a
3
+ metadata.gz: fd27576a058e95f92fd4c50fc1f5da0e058d0b7f93c3f114b88757a08651dd29
4
+ data.tar.gz: f429f5fc246fcd7cb043170a8166b7bc06fa04125aa4c89d6fe196b4c5bead31
5
5
  SHA512:
6
- metadata.gz: 9efc8715d5ca42841968eaa18ea0c611c57bc08734d6ebff1fdd79e0139acbabe2a50416fedd431e38f2ea74007c6c854387dd96cfc08dd6a36affd1d9808929
7
- data.tar.gz: aca4c137a6550bb30ef6d5c0254ddba6bde197b647c3a0c94f73a0a9090dd6d1256a46da17c6ba9091b197ff14c6b1695eb5361901c4eebe6ed3aeba235100f0
6
+ metadata.gz: c58b5116d0b2a0ac0acf829612cdf46ee3ec1ef08879d189bbf94170248ac8cbf6a540601de6794bf6f03086e5af4e2f555291ac5d2de22a5405f1fb61ab066a
7
+ data.tar.gz: bf580a74fcb95fc328f7d0564877804ef642783442254af86d436ae853b89d88f71cd5abb6cff95ba56ed38992261557049350081bad9d35d63a80ce7ebbde96
@@ -123,7 +123,7 @@ module Sequel
123
123
  # can :remove, AllowGroupAdmin, AllowSelfRemove
124
124
  # can :remove_all, AllowGroupAdmin
125
125
  # end
126
- sig { params(name: Symbol, block: T.proc.void).void }
126
+ sig { params(name: Symbol, block: T.proc.bind(AssociationPrivacyDSL).void).void }
127
127
  def association(name, &block)
128
128
  resolver = ->(policies) { resolve_policies(policies) }
129
129
  dsl = AssociationPrivacyDSL.new(@model_class, name, resolver)
@@ -260,7 +260,7 @@ module Sequel
260
260
  # can :edit, P::AllowSelf, P::AllowAdmins
261
261
  # field :email, P::AllowSelf
262
262
  # end
263
- sig { params(block: T.proc.void).void }
263
+ sig { params(block: T.proc.bind(PrivacyDSL).void).void }
264
264
  def privacy(&block)
265
265
  if privacy_finalized?
266
266
  Kernel.raise Sequel::Privacy::PrivacyAlreadyFinalizedError, "Privacy already finalized for #{self}"
@@ -302,6 +302,8 @@ module Sequel
302
302
  vc = instance_variable_get(:@viewer_context)
303
303
 
304
304
  unless vc
305
+ return original_method.bind(self).() if T.unsafe(self.class).allow_unsafe_access?
306
+
305
307
  Kernel.raise Sequel::Privacy::MissingViewerContext,
306
308
  "#{self.class}##{field} requires a ViewerContext"
307
309
  end
@@ -518,6 +520,8 @@ module Sequel
518
520
  vc = instance_variable_get(:@viewer_context)
519
521
 
520
522
  unless vc
523
+ return original.bind(self).(obj) if T.unsafe(self.class).allow_unsafe_access?
524
+
521
525
  Kernel.raise Sequel::Privacy::MissingViewerContext,
522
526
  "Cannot #{method_name} without a viewer context"
523
527
  end
@@ -548,6 +552,8 @@ module Sequel
548
552
  vc = instance_variable_get(:@viewer_context)
549
553
 
550
554
  unless vc
555
+ return original.bind(self).(obj) if T.unsafe(self.class).allow_unsafe_access?
556
+
551
557
  Kernel.raise Sequel::Privacy::MissingViewerContext,
552
558
  "Cannot #{method_name} without a viewer context"
553
559
  end
@@ -578,6 +584,8 @@ module Sequel
578
584
  vc = instance_variable_get(:@viewer_context)
579
585
 
580
586
  unless vc
587
+ return original.bind(self).() if T.unsafe(self.class).allow_unsafe_access?
588
+
581
589
  Kernel.raise Sequel::Privacy::MissingViewerContext,
582
590
  "Cannot #{method_name} without a viewer context"
583
591
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Sequel
5
5
  module Privacy
6
- VERSION = '0.2.0'
6
+ VERSION = '0.3'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-privacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Bales