Class: CanTango::Builder::Permit::Role

Inherits:
Base
  • Object
show all
Includes:
Helpers::Debug
Defined in:
lib/cantango/roles_ext/builder/permit/role.rb

Instance Method Summary collapse

Instance Method Details

#buildArray<RoleGroupPermit::Base>

builds a list of Permits for each role of the current ability user (or account)

Returns:

  • (Array<RoleGroupPermit::Base>)

    the role permits built for this ability



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cantango/roles_ext/builder/permit/role.rb', line 8

def build
  if roles.empty?
    debug "Not building any RolePermit"
    return []
  end
  roles.inject([]) do |permits, role|
    debug "Building RolePermit for #{role}"
    (permits << create_permit(role)) if valid?(role.to_sym)
    permits
  end.compact
end