Class: ProxES::RequestPolicy::Scope
- Inherits:
-
Object
- Object
- ProxES::RequestPolicy::Scope
- Defined in:
- lib/proxes/policies/request_policy.rb
Direct Known Subclasses
ProxES::Request::BulkPolicy::Scope, ProxES::Request::CatPolicy::Scope, ProxES::Request::CreatePolicy::Scope, ProxES::Request::IndexPolicy::Scope, ProxES::Request::MgetPolicy::Scope, ProxES::Request::MsearchPolicy::Scope, ProxES::Request::RootPolicy::Scope, ProxES::Request::SearchPolicy::Scope, ProxES::Request::SnapshotPolicy::Scope, ProxES::Request::StatsPolicy::Scope
Instance Attribute Summary collapse
-
#scope ⇒ Object
(also: #request)
readonly
Returns the value of attribute scope.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(user, scope) ⇒ Scope
constructor
A new instance of Scope.
- #permissions ⇒ Object
- #resolve ⇒ Object
Constructor Details
Instance Attribute Details
#scope ⇒ Object (readonly) Also known as: request
Returns the value of attribute scope.
41 42 43 |
# File 'lib/proxes/policies/request_policy.rb', line 41 def scope @scope end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
41 42 43 |
# File 'lib/proxes/policies/request_policy.rb', line 41 def user @user end |
Instance Method Details
#permissions ⇒ Object
58 59 60 |
# File 'lib/proxes/policies/request_policy.rb', line 58 def @permissions ||= Permission.for_user(user).for_request(request) end |
#resolve ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/proxes/policies/request_policy.rb', line 49 def resolve return .map(&:index) if request.indices == ['*'] || request.indices == ['_all'] || request.indices.blank? request.indices.select do |idx| idx = idx[1..-1] if idx[0] == '-' .find { |perm| perm.index_regex.match idx } end end |