Skip to content

Commit

Permalink
Fixes after manual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Apr 30, 2021
1 parent b724476 commit 7dd09fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
29 changes: 16 additions & 13 deletions src/lib/y2users/config.rb
Expand Up @@ -80,8 +80,8 @@ def system(reader: nil, force_read: false)
def initialize(name)
@name = name

@users_manager = ElementManager.new(config)
@groups_manager = ElementManager.new(config)
@users_manager = ElementManager.new(self)
@groups_manager = ElementManager.new(self)

self.class.register(self)
end
Expand Down Expand Up @@ -135,6 +135,16 @@ def clone_as(name)
config
end

# Generates the id for the next attached user or group
#
# FIXME: This method should not be public
#
# @return [Integer]
def self.next_element_id
@last_element_id ||= 0
@last_element_id += 1
end

protected

# Clones a given user or group and attaches it into this config
Expand All @@ -161,16 +171,6 @@ def clone_element(element)
# @return [ElementManager]
attr_reader :groups_manager

# Generates the id for the next attached user or group
#
# @return [Integer]
def self.next_element_id
@last_element_id ||= 0
@last_element_id += 1
end

private_class_method(:next_element_id)

# Attaches an user or group
#
# An id is assigned to the given user/group, if needed.
Expand All @@ -194,6 +194,9 @@ class ElementManager
# @return [Array<User, Group>]
attr_reader :elements

# @return [Config]
attr_reader :config

# Constructor
#
# @param config [Config]
Expand Down Expand Up @@ -224,7 +227,7 @@ def detach(element)
index = @elements.find_index { |e| e.is?(element) }
@elements.delete_at(index) if index

element.assing_config(nil)
element.assign_config(nil)
element.assign_internal_id(nil)
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/lib/y2users/config_element.rb
Expand Up @@ -83,8 +83,8 @@ def is?(other)
# @return [User, Group]
def clone
cloned = super
cloned.config = nil
cloned.id = nil
cloned.assign_config(nil)
cloned.assign_internal_id(nil)

cloned
end
Expand Down

0 comments on commit 7dd09fe

Please sign in to comment.