Class: Permisi::Config
- Inherits:
-
Object
- Object
- Permisi::Config
- Defined in:
- lib/permisi/config.rb
Defined Under Namespace
Classes: InvalidCacheStore
Constant Summary collapse
- NULL_CACHE_STORE =
ActiveSupport::Cache::NullStore.new
Instance Attribute Summary collapse
-
#default_permissions ⇒ Object
readonly
Returns the value of attribute default_permissions.
-
#mute_pre_0_1_4_warning ⇒ Object
Returns the value of attribute mute_pre_0_1_4_warning.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
Instance Method Summary collapse
- #backend ⇒ Object
- #backend=(chosen_backend) ⇒ Object
- #cache_store ⇒ Object
- #cache_store=(cache_store) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 |
# File 'lib/permisi/config.rb', line 12 def initialize @permissions = ::HashWithIndifferentAccess.new @default_permissions = ::HashWithIndifferentAccess.new end |
Instance Attribute Details
#default_permissions ⇒ Object (readonly)
Returns the value of attribute default_permissions.
9 10 11 |
# File 'lib/permisi/config.rb', line 9 def @default_permissions end |
#mute_pre_0_1_4_warning ⇒ Object
Returns the value of attribute mute_pre_0_1_4_warning.
10 11 12 |
# File 'lib/permisi/config.rb', line 10 def mute_pre_0_1_4_warning @mute_pre_0_1_4_warning end |
#permissions ⇒ Object
Returns the value of attribute permissions.
9 10 11 |
# File 'lib/permisi/config.rb', line 9 def @permissions end |
Instance Method Details
#backend ⇒ Object
34 35 36 |
# File 'lib/permisi/config.rb', line 34 def backend @backend || Backend::NullBackend end |
#backend=(chosen_backend) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/permisi/config.rb', line 17 def backend=(chosen_backend) chosen_backend = "::Permisi::Backend::#{chosen_backend.to_s.classify}".constantize if chosen_backend.is_a? Symbol if !mute_pre_0_1_4_warning && chosen_backend == Backend::ActiveRecord warn <<~MESSAGE WARNING: If you are upgrading from Permisi <v0.1.4, please create the following migration: `add_index :permisi_actor_roles, [:actor_id, :role_id], unique: true` MESSAGE end @backend = chosen_backend rescue NameError raise Backend::InvalidBackend end |
#cache_store ⇒ Object
50 51 52 |
# File 'lib/permisi/config.rb', line 50 def cache_store @cache_store || NULL_CACHE_STORE end |
#cache_store=(cache_store) ⇒ Object
44 45 46 47 48 |
# File 'lib/permisi/config.rb', line 44 def cache_store=(cache_store) raise InvalidCacheStore unless cache_store.respond_to?(:fetch) @cache_store = cache_store end |