Class: MarbleGate::Access
- Inherits:
-
Object
- Object
- MarbleGate::Access
- Defined in:
- lib/marble_gate/access.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #for_authorizer?(model_class) ⇒ Boolean
- #for_model?(model) ⇒ Boolean
-
#initialize(context, action, *args) ⇒ Access
constructor
A new instance of Access.
- #user ⇒ Object
Constructor Details
#initialize(context, action, *args) ⇒ Access
Returns a new instance of Access.
13 14 15 16 |
# File 'lib/marble_gate/access.rb', line 13 def initialize(context, action, *args) @context, @action = context, action.to_sym @args = args end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/marble_gate/access.rb', line 11 def context @context end |
Instance Method Details
#for_authorizer?(model_class) ⇒ Boolean
25 26 27 28 |
# File 'lib/marble_gate/access.rb', line 25 def (model_class) cls = auth_class(model_class) cls.send(choose_action(cls), *@args) end |
#for_model?(model) ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/marble_gate/access.rb', line 18 def for_model?(model) return (model) if model.is_a?(Class) obj = auth_class(model.class).new(model) obj.send(choose_action(obj), *@args) end |
#user ⇒ Object
30 31 32 |
# File 'lib/marble_gate/access.rb', line 30 def user context.send(MarbleGate.current_user_method_name) end |