Class: HasStrongPolicy::PolicySet::Proxy
- Inherits:
-
Object
- Object
- HasStrongPolicy::PolicySet::Proxy
- Defined in:
- lib/has_strong_policy/policy_set.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#set ⇒ Object
readonly
Returns the value of attribute set.
Instance Method Summary collapse
- #apply(*args) ⇒ Object
- #as(role) ⇒ Object
-
#initialize(conditions, set, definition) ⇒ Proxy
constructor
A new instance of Proxy.
- #on(action) ⇒ Object
- #permitted(*args) ⇒ Object
- #required(*args) ⇒ Object
- #with_condition(condition, &block) ⇒ Object
Constructor Details
#initialize(conditions, set, definition) ⇒ Proxy
Returns a new instance of Proxy.
19 20 21 22 23 |
# File 'lib/has_strong_policy/policy_set.rb', line 19 def initialize(conditions, set, definition) @conditions = conditions @definition = definition @set = set end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
17 18 19 |
# File 'lib/has_strong_policy/policy_set.rb', line 17 def conditions @conditions end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
17 18 19 |
# File 'lib/has_strong_policy/policy_set.rb', line 17 def definition @definition end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
17 18 19 |
# File 'lib/has_strong_policy/policy_set.rb', line 17 def set @set end |
Instance Method Details
#apply(*args) ⇒ Object
25 26 27 |
# File 'lib/has_strong_policy/policy_set.rb', line 25 def apply(*args) definition.apply(*args) end |
#as(role) ⇒ Object
43 44 45 46 47 |
# File 'lib/has_strong_policy/policy_set.rb', line 43 def as(role) with_condition({:as => role}) do |definition| yield definition end end |
#on(action) ⇒ Object
37 38 39 40 41 |
# File 'lib/has_strong_policy/policy_set.rb', line 37 def on(action) with_condition({:action => action}) do |definition| yield definition end end |
#permitted(*args) ⇒ Object
33 34 35 |
# File 'lib/has_strong_policy/policy_set.rb', line 33 def permitted(*args) definition.permitted(*args) end |
#required(*args) ⇒ Object
29 30 31 |
# File 'lib/has_strong_policy/policy_set.rb', line 29 def required(*args) definition.required(*args) end |
#with_condition(condition, &block) ⇒ Object
49 50 51 |
# File 'lib/has_strong_policy/policy_set.rb', line 49 def with_condition(condition, &block) set.with_condition(conditions.merge(condition), definition, &block) end |