Class: LcpRuby::Groups::HostLoader

Inherits:
Object
  • Object
show all
Includes:
Contract
Defined in:
lib/lcp_ruby/groups/host_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter) ⇒ HostLoader

Returns a new instance of HostLoader.



6
7
8
# File 'lib/lcp_ruby/groups/host_loader.rb', line 6

def initialize(adapter)
  @adapter = adapter
end

Instance Method Details

#all_group_namesArray<String>

Delegates to the host adapter.

Returns:

  • (Array<String>)


12
13
14
# File 'lib/lcp_ruby/groups/host_loader.rb', line 12

def all_group_names
  @adapter.all_group_names
end

#groups_for_user(user) ⇒ Array<String>

Delegates to the host adapter.

Parameters:

  • user (Object)

Returns:

  • (Array<String>)


19
20
21
# File 'lib/lcp_ruby/groups/host_loader.rb', line 19

def groups_for_user(user)
  @adapter.groups_for_user(user)
end

#roles_for_group(group_name) ⇒ Array<String>

Delegates to the host adapter.

Parameters:

  • group_name (String)

Returns:

  • (Array<String>)


26
27
28
# File 'lib/lcp_ruby/groups/host_loader.rb', line 26

def roles_for_group(group_name)
  @adapter.roles_for_group(group_name)
end

#roles_for_user(user) ⇒ Array<String>

Delegates to the host adapter when it provides an optimized implementation. Otherwise falls back to the default composition.

Parameters:

  • user (Object)

Returns:

  • (Array<String>)


45
46
47
48
49
50
51
# File 'lib/lcp_ruby/groups/host_loader.rb', line 45

def roles_for_user(user)
  if @adapter.respond_to?(:roles_for_user)
    @adapter.roles_for_user(user)
  else
    super
  end
end

#user_ids_for_group(group_name) ⇒ Array<Integer>

Delegates to the host adapter when it provides the method.

Parameters:

  • group_name (String)

Returns:

  • (Array<Integer>)


33
34
35
36
37
38
39
# File 'lib/lcp_ruby/groups/host_loader.rb', line 33

def user_ids_for_group(group_name)
  if @adapter.respond_to?(:user_ids_for_group)
    @adapter.user_ids_for_group(group_name)
  else
    []
  end
end