Class: Goldberg::Role

Inherits:
ActiveRecord::Base show all
Includes:
Model
Defined in:
lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included

Methods inherited from ActiveRecord::Base

#associated_valid?, #no_errors_in_associated?, #save_associated, #save_associated!, #save_with_unsaved_flag, #to_label, #unsaved=, #unsaved?

Class Method Details

.rebuild_cacheObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb', line 16

def Role.rebuild_cache
  roles = Role.find(:all)
  
  for role in roles do
  role.cache = nil ; role.save # we have to do this to clear it
    
    role.cache = Hash.new
    role.rebuild_credentials
    role.rebuild_menu
    role.save
  end
end

Instance Method Details

#get_parentsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb', line 39

def get_parents
  parents = Array.new
  seen = Hash.new

  current = self.id
  
  while current
    role = Role.find(current)
    if role 
      if not seen.has_key?(role.id)
        parents << role
        seen[role.id] = true
        current = role.parent_id
      else
        current = nil
      end
    else
      current = nil
    end
  end

  return parents
end

#get_start_pathObject



63
64
65
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb', line 63

def get_start_path
  self.start_path || Goldberg.settings.get_start_path
end

#rebuild_credentialsObject

class << self



30
31
32
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb', line 30

def rebuild_credentials
  self.cache[:credentials] = Credentials.new(self.id)
end

#rebuild_menuObject



34
35
36
37
# File 'lib/six-updater-web/vendor/plugins/goldberg/app/models/goldberg/role.rb', line 34

def rebuild_menu
  menu = Menu.new(self)
  self.cache[:menu] = menu
end