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
Instance Method Details
#organization ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/models/current.rb', line 38 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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/current.rb', line 21 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 |
#organization_id ⇒ Object
48 49 50 |
# File 'app/models/current.rb', line 48 def organization_id organization&.id end |