lib/atome/genesis/generators/identity.rb in atome-0.5.4.1.9 vs lib/atome/genesis/generators/identity.rb in atome-0.5.5.6.4
- old
+ new
@@ -1,100 +1,61 @@
# frozen_string_literal: true
-new({ particle: :attach })
-new({ sanitizer: :attach }) do |parents_ids|
- # puts "=> attach it! : #{parents_ids} <="
-
- # 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 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]
-
- # the condition below is needed when user passed a hash instead of the id of the child cf :
- parent_type_container = if parents_found.atome[current_type].instance_of? Array
- parents_found.atome[current_type]
- else
- [parents_found.atome[current_type][:id]]
- end
- # here we add the child into it's parents type container
- 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
- parents_ids
-end
-
-new({ particle: :attached })
-new({ sanitizer: :attached }) do |children_ids|
- # puts "=> attached now! : #{children_ids}<="
- # 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 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
- @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
- @atome[child_found_type]
- else
- [@atome[child_found_type][:id]]
- end
- child_type_container << child_id
- # TODO : factorise the code above
- child_found.atome[:attach] = [parents_found]
- end
-end
-
-new({ particle: :detached, store: false })
-new({ sanitizer: :detached }) do |values|
- if values.instance_of? Array
- values.each do |value|
- detach_atome(value)
- end
- else
- detach_atome(values)
- # we sanitize the values so it always return an array to the renderer
- values = [values]
- end
- values
-end
-
-
-
new({ particle: :real })
new({ particle: :type })
new({ particle: :id })
new({ sanitizer: :id }) do |params|
- if @atome[:id] != params
- Universe.update_atome_id(params, self, @atome[:id])
+ # first we sanitize the the id below
+ params = params.to_sym
+ if @id.to_sym != params
+ Universe.update_atome_id(params, self, @id)
else
Universe.add_to_atomes(params, self)
end
params
end
new({ particle: :name })
new({ particle: :active })
+# new({ particle: :entangled, type: :array })
+# new({ particle: :clones }) do |clones_found|
+# clones_found.each_with_index do |clone_found, index|
+# particles_entangled = clone_found[:entangled] ||= []
+# clone_id = "#{particles[:id]}_clone_#{index}"
+# original_id = atome[:id]
+# clone_found[:id] = clone_id
+# clone_found = particles.merge(clone_found)
+# clone_found.delete(:html_object)
+# cloned_atome = Atome.new(clone_found)
+# monitor({ atomes: [original_id], particles: particles_entangled }) do |_atome, particle, value|
+# cloned_atome.send(particle, value)
+# end
+# end
+# end
+new({ particle: :markup })
+new({particle: :bundle})
+new({ particle: :data })
-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]
- 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
+new({particle: :category, store: false}) do |category_names|
+ category_names=[category_names] unless category_names.instance_of? Array
+ category_names.each do |category_name|
+ @category << category_name
end
+end
+# The selection particle is used by current user to store selected atomes
+new(particle: :selection)
+
+new({ read: :selection }) do |params_get|
+ selector = grab(:selector)
+ selector.collect = params_get
+ selector
+end
+
+new(particle: :selected) do |params|
+ if params == true
+ grab(Universe.current_user).selection << @id
+ elsif params == false
+ grab(Universe.current_user).selection.delete(@id)
+ else
+ # TODO: for future use
+ end
+ params
end