Class: LinkedRails::EnumValuePolicy::Scope

Inherits:
Scope
  • Object
show all
Defined in:
app/policies/linked_rails/enum_value_policy.rb

Instance Method Summary collapse

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

#resolveObject



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| valid_options.include?(option.key) }
end