Class: Recurso::Config
- Inherits:
-
Object
- Object
- Recurso::Config
- Includes:
- Singleton
- Defined in:
- lib/recurso/config.rb
Constant Summary collapse
- DEFAULT_IDENTITY_FOREIGN_KEY =
:identity_id
- DEFAULT_PERMISSION_CLASS_NAME =
'Permission'
Instance Attribute Summary collapse
-
#actions_for_default ⇒ Object
Returns the value of attribute actions_for_default.
-
#default_level ⇒ Object
Returns the value of attribute default_level.
-
#default_permission_class_name ⇒ Object
Returns the value of attribute default_permission_class_name.
-
#global_relations ⇒ Object
Returns the value of attribute global_relations.
-
#identity_foreign_key ⇒ Object
Returns the value of attribute identity_foreign_key.
-
#levels ⇒ Object
Returns the value of attribute levels.
-
#levels_for_action ⇒ Object
Returns the value of attribute levels_for_action.
-
#permission_class_name ⇒ Object
Returns the value of attribute permission_class_name.
Instance Method Summary collapse
- #identity_foreign_key_for(model) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #model_specific(value, model) ⇒ Object
- #permission_class_name_for(identity_model) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/recurso/config.rb', line 18 def initialize @levels_for_action = { view: [:admin, :editor, :viewer], modify: [:admin, :editor], administer: [:admin], } @actions_for_default = { open: [:view, :modify], closed: [:view], secret: [], } @levels = [:member, :admin, :editor, :viewer] @default_level = :member @identity_foreign_key = DEFAULT_IDENTITY_FOREIGN_KEY @permission_class_name = DEFAULT_PERMISSION_CLASS_NAME @global_relations = [] end |
Instance Attribute Details
#actions_for_default ⇒ Object
Returns the value of attribute actions_for_default.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def actions_for_default @actions_for_default end |
#default_level ⇒ Object
Returns the value of attribute default_level.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def default_level @default_level end |
#default_permission_class_name ⇒ Object
Returns the value of attribute default_permission_class_name.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def @default_permission_class_name end |
#global_relations ⇒ Object
Returns the value of attribute global_relations.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def global_relations @global_relations end |
#identity_foreign_key ⇒ Object
Returns the value of attribute identity_foreign_key.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def identity_foreign_key @identity_foreign_key end |
#levels ⇒ Object
Returns the value of attribute levels.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def levels @levels end |
#levels_for_action ⇒ Object
Returns the value of attribute levels_for_action.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def levels_for_action @levels_for_action end |
#permission_class_name ⇒ Object
Returns the value of attribute permission_class_name.
9 10 11 |
# File 'lib/recurso/config.rb', line 9 def @permission_class_name end |
Instance Method Details
#identity_foreign_key_for(model) ⇒ Object
50 51 52 |
# File 'lib/recurso/config.rb', line 50 def identity_foreign_key_for(model) model_specific(identity_foreign_key, model) || DEFAULT_IDENTITY_FOREIGN_KEY end |
#model_specific(value, model) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/recurso/config.rb', line 42 def model_specific(value, model) if value.respond_to?(:call) value.call(model) else value end end |
#permission_class_name_for(identity_model) ⇒ Object
54 55 56 |
# File 'lib/recurso/config.rb', line 54 def (identity_model) model_specific(, identity_model) || DEFAULT_PERMISSION_CLASS_NAME end |