Class: RbacCore::Mapper
- Inherits:
-
Object
- Object
- RbacCore::Mapper
- Defined in:
- lib/rbac_core/mapper.rb
Instance Method Summary collapse
- #group(name, **constraints, &block) ⇒ Object
-
#initialize(set, **constraints) ⇒ Mapper
constructor
:nodoc:.
- #permission(name, default: false, **options, &block) ⇒ Object
Constructor Details
#initialize(set, **constraints) ⇒ Mapper
:nodoc:
5 6 7 8 |
# File 'lib/rbac_core/mapper.rb', line 5 def initialize(set, **constraints) #:nodoc: @constraints = constraints @set = set end |
Instance Method Details
#group(name, **constraints, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbac_core/mapper.rb', line 15 def group(name, **constraints, &block) raise ArgumentError, "`name` can't be blank" if name.blank? raise ArgumentError, "must provide a block" unless block_given? = if @set.nested_classes.has_key?(name) @set.nested_classes[name] else klass = PermissionSet.derive "#{name.to_s.classify}" @set.(name, anonymous_class: klass) klass end .draw(@constraints.merge(constraints), &block) self end |
#permission(name, default: false, **options, &block) ⇒ Object
10 11 12 13 |
# File 'lib/rbac_core/mapper.rb', line 10 def (name, default: false, **, &block) @set. name, default, @constraints.merge(), &block self end |