Module: ActiveSecurity::Restricted::RestrictedScope

Defined in:
lib/active_security/restricted.rb

Instance Method Summary collapse

Instance Method Details

#restrictedObject

Returns a scope that includes the active_security restricted hooks.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/active_security/restricted.rb', line 55

def restricted
  # Guess what? This causes Rails to invoke `extend` on the scope, which has
  # the well-known effect of blowing away Ruby's method cache. It would be
  # possible to make this more performant by subclassing the model's
  # relation class, extending that, and returning an instance of it in this
  # method. However, using Rails' public API improves compatibility
  # and maintainability. If you'd like to improve the performance, your
  # efforts would be best directed at improving it at the root cause
  # of the problem - in Rails - because it would benefit more people.
  all.extending(
    active_security_config.finder_methods,
    active_security_config.restricted_hooks,
  )
end