Sha256: 510b533545335145189ae47ebe8972dae019bfce323c265365053d3a7429bf79
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'active_support/core_ext/class/attribute.rb' require 'periscope/permission_set' module Periscope module Adapters module Abstract extend ActiveSupport::Concern included do class_attribute :_accessible_scopes class_attribute :_protected_scopes class_attribute :_periscope_authorizer end module ClassMethods def periscope(*) raise NotImplementedError end def scope_protected(*scopes) self._protected_scopes = protected_scopes + scopes self._periscope_authorizer = _protected_scopes end alias_method :down_periscope, :scope_protected def scope_accessible(*scopes) self._accessible_scopes = accessible_scopes + scopes self._periscope_authorizer = _accessible_scopes end alias_method :up_periscope, :scope_accessible def protected_scopes self._protected_scopes ||= BlackList.new.tap do |list| list.logger = logger if respond_to?(:logger) end end def accessible_scopes self._accessible_scopes ||= WhiteList.new(scopes_accessible_by_default).tap do |list| list.logger = logger if respond_to?(:logger) end end def periscope_authorizer self._periscope_authorizer ||= accessible_scopes end def scopes_accessible_by_default [] end end module InstanceMethods protected def sanitize_for_search(params) search_authorizer.sanitize(params) end def search_authorizer self.class.periscope_authorizer end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
periscope-0.1.0 | lib/periscope/adapters/abstract.rb |