Class: CanTango::Permits::RolePermit::Builder

Inherits:
CanTango::PermitEngine::Builder::Base show all
Includes:
Helpers::Debug
Defined in:
lib/cantango/permits/role_permit/builder.rb

Instance Attribute Summary

Attributes inherited from CanTango::PermitEngine::Builder::Base

#ability

Instance Method Summary collapse

Methods included from Helpers::Debug

#debug

Methods inherited from CanTango::PermitEngine::Builder::Base

#initialize

Constructor Details

This class inherits a constructor from CanTango::PermitEngine::Builder::Base

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



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cantango/permits/role_permit/builder.rb', line 9

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

#nameObject



21
22
23
# File 'lib/cantango/permits/role_permit/builder.rb', line 21

def name
  :role
end