Method: Lockdown::Database.sync_with_db

Defined in:
lib/lockdown/database.rb

.sync_with_dbObject

This is very basic and could be handled better using orm specific functionality, but I wanted to keep it generic to avoid creating an interface for each the different orm implementations. We’ll see how it works…



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lockdown/database.rb', line 10

def sync_with_db
  @permissions = Lockdown::Configuration.permission_names
  @user_groups = Lockdown::Configuration.user_group_names

  unless ::Permission.table_exists? && Lockdown.user_group_class.table_exists?
    Lockdown.logger.info ">> Lockdown tables not found.  Skipping database sync."
    return
  end

  create_new_permissions

  delete_extinct_permissions

  maintain_user_groups
end