Class: Acl9::Dsl::Base
- Inherits:
-
Object
- Object
- Acl9::Dsl::Base
- Includes:
- Prepositions
- Defined in:
- lib/acl9/controller_extensions/dsl_base.rb
Direct Known Subclasses
Constant Summary
Constants included from Prepositions
Prepositions::VALID_PREPOSITIONS
Instance Attribute Summary collapse
-
#allows ⇒ Object
readonly
Returns the value of attribute allows.
-
#denys ⇒ Object
readonly
Returns the value of attribute denys.
Instance Method Summary collapse
- #acl_block!(&acl_block) ⇒ Object
- #allowance_expression ⇒ Object (also: #to_s)
- #default_action ⇒ Object
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
Methods included from Prepositions
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 10 def initialize(*args) @default_action = nil @allows = [] @denys = [] @original_args = args end |
Instance Attribute Details
#allows ⇒ Object (readonly)
Returns the value of attribute allows.
8 9 10 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 8 def allows @allows end |
#denys ⇒ Object (readonly)
Returns the value of attribute denys.
8 9 10 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 8 def denys @denys end |
Instance Method Details
#acl_block!(&acl_block) ⇒ Object
17 18 19 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 17 def acl_block!(&acl_block) instance_eval(&acl_block) end |
#allowance_expression ⇒ Object Also known as: to_s
25 26 27 28 29 30 31 32 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 25 def allowance_expression allowed_expr = @allows.any? ? @allows.map { |clause| "(#{clause})" }.join(' || ') : 'false' not_denied_expr = @denys.any? ? @denys.map { |clause| "!(#{clause})" }.join(' && ') : 'true' [allowed_expr, not_denied_expr]. map { |expr| "(#{expr})" }. join(default_action == :deny ? ' && ' : ' || ') end |
#default_action ⇒ Object
21 22 23 |
# File 'lib/acl9/controller_extensions/dsl_base.rb', line 21 def default_action @default_action.nil? ? :deny : @default_action end |