lib/atome/genesis/generators/identity.rb in atome-0.5.3.8.8 vs lib/atome/genesis/generators/identity.rb in atome-0.5.4.0.9
- old
+ new
@@ -1,13 +1,13 @@
# frozen_string_literal: true
new({ particle: :attach })
new({ sanitizer: :attach }) do |parents_ids|
- parents_ids = parents_ids.value if parents_ids.instance_of? Atome
+ parents_ids = parents_ids if parents_ids.instance_of? Atome
parents_ids = [parents_ids] unless parents_ids.instance_of?(Array)
parents_ids.each do |parents_id|
- parents_id = parents_id.value if parents_id.instance_of? Atome
+ parents_id = parents_id if parents_id.instance_of? Atome
parents_found = grab(parents_id)
# TODO : factorise the code below
current_type = atome[:type]
parents_found.atome[current_type] = [] unless parents_found.atome[current_type]
@@ -21,27 +21,23 @@
parent_type_container << atome[:id]
# TODO : factorise the code above
parents_found.atome[:attached] = [] unless parents_found.atome[:attached]
parents_found.atome[:attached] << atome[:id]
end
- # atome[:parents]=atome[:parents] | parents_ids
- # atome[:parents].concat(parents_ids).uni
- # puts "==> #{id} : #{self}"
- # puts "====> id : #{id}, #{parents_ids} #{atome[:parents]}, #{atome[:parents].class} : #{atome[:parents].class}"
parents_ids
end
new({ particle: :attached })
new({ sanitizer: :attached }) do |children_ids|
- children_ids = children_ids.value if children_ids.instance_of? Atome
+ children_ids = children_ids if children_ids.instance_of? Atome
children_ids = [children_ids] unless children_ids.instance_of?(Array)
children_ids.each do |child_id|
- child_id = child_id.value if child_id.instance_of? Atome
+ child_id = child_id if child_id.instance_of? Atome
child_found = grab(child_id)
parents_found = @atome[:id]
# TODO : factorise the code below
- child_found_type = child_found.type.value
+ child_found_type = child_found.type
@atome[child_found_type] = [] unless @atome[child_found_type]
# the condition below is needed when user passed a hash instead of the id of the child cf :
# circle(color: {red: 0, green: 1}) instead of color({id: :the_col}); circle(color: [:the_col])
child_type_container = if @atome[child_found_type].instance_of? Array
@@ -49,12 +45,10 @@
else
[@atome[child_found_type][:id]]
end
child_type_container << child_id
# TODO : factorise the code above
-
- # child_found.family(parents_found)
child_found.atome[:attach] = [parents_found]
end
end
new({ particle: :detached, store: false })
@@ -65,36 +59,15 @@
detach_atome(value)
end
else
detach_atome(values)
# we sanitize the values so it always return an array to the renderer
- values=[values]
+ values = [values]
end
values
end
new({ particle: :type })
-
-# new({ particle: :parents })
-# new({ sanitizer: :parents }) do |params|
-# params = [params] unless params.instance_of? Array
-# sanitized_params = []
-# params.each do |parents_id|
-# parents_id = parents_id.value if parents_id.instance_of? Atome
-# sanitized_params << parents_id
-# parents_found = grab(parents_id)
-# # TODO : factorise the code below
-# current_type = atome[:type]
-# parents_found.atome[current_type] = [] unless parents_found.atome[current_type]
-# parents_found.atome[current_type] << atome[:id]
-# # TODO : factorise the code above
-# # TODO : check if we can remove the family
-# family(parents_id)
-# end
-# sanitized_params
-# end
-
-# new({ particle: :family })
new({ particle: :id })
new({ sanitizer: :id }) do |params|
if @atome[:id] != params
Universe.update_atome_id(params, self, @atome[:id])
else