lib/authz/scopables/base.rb
# Returns true if the given instance_to_check is within the
# scoping privileges of the given keyword, optionally passing
# the requester to aide the resolution of the keyword.
Returns true if the given instance_to_check is within the
scoping privileges of the given keyword, optionally passing
the requester to aide the resolution of the keyword.
Returns true if the given instance_to_check is within the scoping privileges of the given keyword optionally passing the requester to aide the resolution of the keyword .
def within_scope_of_keyword?(instance_to_check, keyword, requester)
        keyword = normalize_if_special_keyword(keyword)
        return true if keyword == :all
        instance_scope_ids = associated_scoping_instances_ids(instance_to_check)
        role_scope_ids = resolve_keyword!(keyword, requester)
        if instance_scope_ids.any?
          (instance_scope_ids & role_scope_ids).any?
        else
          return false if instance_to_check.class == scoping_class
          role_scope_ids.include? nil
        end
      end
def within_scope_of_keyword? ( instance_to_check , keyword , requester ) keyword = normalize_if_special_keyword ( keyword ) return true if keyword == :all instance_scope_ids = associated_scoping_instances_ids ( instance_to_check ) role_scope_ids = resolve_keyword! ( keyword , requester ) if instance_scope_ids . any? ( instance_scope_ids & role_scope_ids ) . any? else return false if instance_to_check . class == scoping_class role_scope_ids . include? nil end end
Returns true if the given instance_to_check is within the
scoping privileges of the given keyword, optionally passing
the requester to aide the resolution of the keyword.
Returns true if the given instance_to_check is within the scoping privileges of the given keyword optionally passing the requester to aide the resolution of the keyword .
# Shortcut treatment for special keywords # Resolution # When instance is associated to scoping class (report with city) # Resolve by intersection # TODO: if this becomes a problem, we could add # another parameter indicating the type of the match # e.g. match: :any, match: :all # "any" If announcement is available in 1,2,3 and I have 3 then I can see it # "all" If I am trying to create an announcement for 1,2, and I only have 1 then it should be denied # When instance is not associated to scoping class # (e.g report with no city, announcement not available, # in any city, city that has not been persisted) # Fix singularity problem that allowed resolved keywords # that include nil to consider non persisted instances # of scoping classes (e.g. a city that has not been saved # yet) within scope. (ultimately allowing the creation # to out of scope)
instance_to_check
keyword
requester