Class: Ruolo::Sync

Inherits:
Object
  • Object
show all
Defined in:
lib/ruolo/sync.rb

Overview

This class manages the actual synchronization of the policy file with the database.

Instance Method Summary collapse

Constructor Details

#initialize(policy_file) ⇒ Ruolo::Sync

Create a new synchronization ojbect.

Parameters:

  • policy_file (String)

    path to the yaml policy file



30
31
32
# File 'lib/ruolo/sync.rb', line 30

def initialize(policy_file)
  @policy_document = YAML.safe_load(File.read(policy_file), symbolize_names: true)
end

Instance Method Details

#sync!void

This method returns an undefined value.

Bring the configured database in sync with the policy file, adding and removing roles, permissions, and the permissions that belong to roles as necessary.



39
40
41
42
43
44
45
# File 'lib/ruolo/sync.rb', line 39

def sync!
  Ruolo.configuration.connection.transaction do
    permissions_diff
    roles_diff
    roles_permissions_diff
  end
end