Module: Checken::Concerns::HasParents

Included in:
Permission, PermissionGroup
Defined in:
lib/checken/concerns/has_parents.rb

Instance Method Summary collapse

Instance Method Details

#parentsArray<Checken::PermissionGroup, Checken::Permission>

Return the parents for ths group



22
23
24
# File 'lib/checken/concerns/has_parents.rb', line 22

def parents
  @key.nil? ? [] : [@group.parents, @group].compact.flatten
end

#pathString

Return the full path to this permission



8
9
10
# File 'lib/checken/concerns/has_parents.rb', line 8

def path
  @key.nil? ? nil : [@group.path, @key].compact.join('.')
end

#path_with_namespaceString

Return the full path to this permission with the namespace



15
16
17
# File 'lib/checken/concerns/has_parents.rb', line 15

def path_with_namespace
  [@schema.config.namespace, path].compact.join(@schema.config.namespace_delimiter)
end

#rootChecken::PermissionGroup

Return the root group



29
30
31
# File 'lib/checken/concerns/has_parents.rb', line 29

def root
  @key.nil? ? self : parents.first
end