Class: LinkedRails::EnumValuePolicy::Scope
- Inherits:
-
Scope
- Object
- Scope
- LinkedRails::EnumValuePolicy::Scope
- Defined in:
- app/policies/linked_rails/enum_value_policy.rb
Instance Method Summary collapse
-
#initialize(context, scope) ⇒ Scope
constructor
A new instance of Scope.
- #resolve ⇒ Object
Constructor Details
#initialize(context, scope) ⇒ Scope
Returns a new instance of Scope.
6 7 8 9 |
# File 'app/policies/linked_rails/enum_value_policy.rb', line 6 def initialize(context, scope) @context = context @scope = scope end |
Instance Method Details
#resolve ⇒ Object
11 12 13 14 15 |
# File 'app/policies/linked_rails/enum_value_policy.rb', line 11 def resolve return scope if scope.blank? || !parent_policy.respond_to?(filter_method) scope.select { |option| .include?(option.key) } end |