Class: ActionAuthorization::Resource
- Inherits:
-
Object
- Object
- ActionAuthorization::Resource
- Defined in:
- lib/authorizer/resource.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(action, actor, *resources, **options) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(action, actor, *resources, **options) ⇒ Resource
Returns a new instance of Resource.
5 6 7 8 9 10 |
# File 'lib/authorizer/resource.rb', line 5 def initialize(action, actor, *resources, **) @action = action @actor = actor @resources = resources @options = end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
3 4 5 |
# File 'lib/authorizer/resource.rb', line 3 def action @action end |
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
3 4 5 |
# File 'lib/authorizer/resource.rb', line 3 def actor @actor end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/authorizer/resource.rb', line 3 def @options end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
3 4 5 |
# File 'lib/authorizer/resource.rb', line 3 def resources @resources end |
Instance Method Details
#get ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/authorizer/resource.rb', line 12 def get return @resources if @resources.nil? return @resources if @resources.length == 0 behavior = @options[:behavior] if !behavior behavior = :filter end case behavior when :allow_all collect_permitted(return_res: true) {|results| results.length > 0} when :deny_all collect_permitted {|results| results.length == @resources.length} when :filter collect_permitted {|results| results.length > 0} end end |