Class: Current
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- Current
- Defined in:
- app/models/current.rb
Overview
rubocop:disable Gitlab/NamespacedClass – We want this to be top level due to scope of use and no namespace due to ease of calling
Defined Under Namespace
Classes: OrganizationAlreadyAssignedError, OrganizationNotAssignedError
Instance Method Summary collapse
-
#cells_claims_leases? ⇒ Boolean
TODO: After updating to Rails 7.2, move this logic to the attribute default.
- #organization ⇒ Object
- #organization=(value) ⇒ Object
Instance Method Details
#cells_claims_leases? ⇒ Boolean
TODO: After updating to Rails 7.2, move this logic to the attribute default.
24 25 26 27 28 29 30 31 32 |
# File 'app/models/current.rb', line 24 def cells_claims_leases? if cells_claims_leases.nil? self.cells_claims_leases = Gitlab.config.cell.enabled && Feature.enabled?(:cells_unique_claims) # rubocop:disable Gitlab/FeatureFlagWithoutActor -- We can't easily tie this to an actor end cells_claims_leases end |
#organization ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/models/current.rb', line 51 def organization unless organization_assigned Gitlab::ErrorTracking.track_and_raise_for_dev_exception(OrganizationNotAssignedError.new) end Gitlab::Organizations::FallbackOrganizationTracker.trigger super end |
#organization=(value) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/current.rb', line 34 def organization=(value) # We want to explicitly allow only one organization assignment per thread # This fits the request/response cycle, but of course for rake tasks/background jobs that use the same thread, # we will need to reset as the first step in execution with Current.reset..if used at those layers. if organization_assigned Gitlab::ErrorTracking.track_and_raise_for_dev_exception(OrganizationAlreadyAssignedError.new) return # when outside of dev/test end self.organization_assigned = true Gitlab::ApplicationContext.push(organization: value) super(value) end |