Class: PgRls::Current
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- PgRls::Current
- Defined in:
- app/models/pg_rls/current.rb
Overview
Current Tenant State
Instance Method Summary collapse
Instance Method Details
#fetch_attribute(attribute) ⇒ Object
14 15 16 17 18 |
# File 'app/models/pg_rls/current.rb', line 14 def fetch_attribute(attribute) klass_name = attribute.to_s.gsub("__", "/").classify send(:"#{attribute}=", klass_name.constantize.first) end |
#reset ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/models/pg_rls/current.rb', line 27 def reset history = Array @attributes[:tenant_history] super @attributes[:tenant_history] = history restore_most_recent_tenant @attributes end |
#tenant=(tenant) ⇒ Object
20 21 22 23 24 25 |
# File 'app/models/pg_rls/current.rb', line 20 def tenant=(tenant) PgRls.current_attributes.each { |key| @attributes[key] = nil } add_tenant_to_history super tenant&.set_rls end |