lib/atome/genesis/generators/identity.rb in atome-0.5.3.7.3 vs lib/atome/genesis/generators/identity.rb in atome-0.5.3.7.8

- old
+ new

@@ -1,46 +1,56 @@ # frozen_string_literal: true new({ particle: :attached }) new({ sanitizer: :attached }) do |params| - unless params.instance_of? Array - params = [params] - end + params = [params] unless params.instance_of? Array params end new({ pre: :attached }) do |children_ids| children_ids.each do |child_id| child_id = child_id.value if child_id.instance_of? Atome child_found = grab(child_id) parents_found = @atome[:id] child_found.family(parents_found) - # parents_found.atome[:attach] = [] unless parents_found.atome[:attach] child_found.atome[:attach] = [parents_found] end end new({ particle: :type }) new({ particle: :children }) -new({ pre: :children }) do |children_ids| - children_ids.each do |child_id| + +new ({ sanitizer: :children }) do |params| + # TODO factorise the line below and 'sanitized_params' for all particle type of Array + params = [params] unless params.instance_of? Array + sanitized_params = [] + params.each do |child_id| child_id = child_id.value if child_id.instance_of? Atome + sanitized_params << child_id child_found = grab(child_id) parents_found = @atome[:id] # FIXME : broadcast may malfunction because of the commented line below, - # FIXME suite : if uncomment object hierreachy is broken (cf Vie Project) - # child_found.family(parents_found) + # FIXME suite : if uncomment object hierarchy is broken (cf Vie Project) + # FIXME : parent child problem may be caused by th eline below + child_found.family(parents_found) child_found.atome[:parents] = [parents_found] end + sanitized_params end + new({ particle: :parents }) -new({ pre: :parents }) do |parents_ids| - parents_ids.each do |parents_id| +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) family(parents_id) parents_found.atome[:children] << atome[:id] end + sanitized_params end + new({ particle: :family }) new({ particle: :link }) new({ particle: :id }) new({ sanitizer: :id }) do |params| if @atome[:id] != params @@ -60,12 +70,14 @@ family(parents_id) parents_found.atome[:attached] = [] unless parents_found.atome[:attached] parents_found.atome[:attached] << atome[:id] end end -new({ particle: :detached }) -new({ particle: :intricate, type: :array }) +new({ particle: :detached }) do |value| + attached.value.delete(value) +end +new({ particle: :intricate, type: :array }) new({ particle: :clones }) do |clones_found| clones_found.each_with_index do |clone_found, index| particles_intricated = clone_found[:intricate] ||= [] clone_id = "#{particles[:id]}_clone_#{index}" original_id = atome[:id] @@ -75,68 +87,5 @@ cloned_atome.monitor({ atomes: [original_id], particles: particles_intricated }) do |_atome, particle, value| cloned_atome.send(particle, value) end end end - -# generator = Genesis.generator -# -# generator.build_particle(:type) -# generator.build_particle(:parents) -# generator.build_particle(:children) -# generator.build_option(:pre_render_parents) do |parents_ids| -# parents_ids.each do |parents_id| -# parents_id = parents_id.value if parents_id.instance_of? Atome -# parents_found = grab(parents_id) -# family(parents_id) -# parents_found.atome[:children] << atome[:id] -# end -# end -# generator.build_option(:pre_render_children) do |children_ids| -# children_ids.each do |child_id| -# child_id = child_id.value if child_id.instance_of? Atome -# child_found = grab(child_id) -# parents_found = @atome[:id] -# # FIXME : broadcast may malfunction because of the commented line below, -# # FIXME suite : if uncomment object hierreachy is broken (cf Vie Project) -# # child_found.family(parents_found) -# child_found.atome[:parents] = [parents_found] -# end -# end -# generator.build_particle(:family, { render: true, store: false }) -# generator.build_particle(:link) do |child_id| -# child_found = grab(child_id) -# child_found.atome[:parents] << @atome[:id] -# child_found.refresh -# end -# generator.build_particle(:id) -# generator.build_sanitizer(:id) -# generator.build_particle(:name) -# generator.build_particle(:active) -# generator.build_particle(:attach) -# generator.build_option(:pre_render_attach) do |parents_ids| -# parents_ids.each do |parents_id| -# parents_id = parents_id.value if parents_id.instance_of? Atome -# parents_found = grab(parents_id) -# family(parents_id) -# parents_found.atome[:attached] = [] unless parents_found.atome[:attached] -# parents_found.atome[:attached] << atome[:id] -# end -# end -# -# generator.build_particle(:detached) do |attach_to_remove| -# attached.value.delete(attach_to_remove) -# end -# generator.build_particle(:intricate, { type: :array }) -# generator.build_particle(:clones) do |clones_found| -# clones_found.each_with_index do |clone_found, index| -# particles_intricated = clone_found[:intricate] ||= [] -# clone_id = "#{particles[:id]}_clone_#{index}" -# original_id = atome[:id] -# clone_found[:id] = clone_id -# clone_found = particles.merge(clone_found) -# cloned_atome = Atome.new({ clone: clone_found }) -# cloned_atome.monitor({ atomes: [original_id], particles: particles_intricated }) do |_atome, particle, value| -# cloned_atome.send(particle, value) -# end -# end -# end