Class: Roleback::Definitions::Scope
- Defined in:
- lib/roleback/definitions/scope.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from RuleBased
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, role:, options: {}, &block) ⇒ Scope
constructor
A new instance of Scope.
- #match(scope) ⇒ Object
- #resource(name, options = {}, &block) ⇒ Object
Methods inherited from RuleBased
Constructor Details
#initialize(name, role:, options: {}, &block) ⇒ Scope
Returns a new instance of Scope.
6 7 8 9 10 11 12 13 14 |
# File 'lib/roleback/definitions/scope.rb', line 6 def initialize(name, role:, options: {}, &block) @name = name @role = role @options = super(role: role, scope: self, resource: ::Roleback::ANY) instance_eval(&block) if block_given? end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/roleback/definitions/scope.rb', line 4 def name @name end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 |
# File 'lib/roleback/definitions/scope.rb', line 25 def ==(other) return false unless other.respond_to?(:name) other.name == name end |
#match(scope) ⇒ Object
20 21 22 23 |
# File 'lib/roleback/definitions/scope.rb', line 20 def match(scope) to_check = scope.is_a?(::Roleback::Definitions::Scope) ? scope.name.to_s : scope.to_s @name.to_s == scope.name.to_s || @name == ::Roleback.any || scope == ::Roleback.any end |
#resource(name, options = {}, &block) ⇒ Object
16 17 18 |
# File 'lib/roleback/definitions/scope.rb', line 16 def resource(name, = {}, &block) ::Roleback::Definitions::Resource.new(name, role: @role, scope: self, options: , &block) end |