# frozen_string_literal: true # main Atome entry here class Atome include Essentials def initialize(new_atome = {}, &atomes_proc) # TODO: atome format should always be as followed : {value: 0.44, unit: :px, opt1: 554} # when using optimised version of atome you must type eg : a.set({left: {value: 33, unit: '%', reference: :center}}) # the keys :renderers, :type and :id should be placed in the first position in the hash @history = {} # @language = :english @callback = {} @tag = {} @selected = false #@metrics = {} @unit = {} @collect = {} @collect = {} @int8= {} @css = {} @id = new_atome[:id] || identity_generator(:element) @type = new_atome[:type] || :element @attached = [] @category = [] # @display = { mode: :default } # @backup={} # mainly used to restore particle when using grid /table /list display mode @html = HTML.new(@id, self) @headless = Headless.new(@id, self) # now we store the proc in a an atome's property called :bloc new_atome[:code] = atomes_proc if atomes_proc # we reorder the hash reordered_atome =reorder_particles(new_atome) # FIXME : try to remove the condition below (it crash in the method : def generator ... in genesis.rb) collapse(reordered_atome) end def js html.object end def particle_creation(element, params, store, rendering, &user_proc) # @store_allow = false params = particle_main(element, params, &user_proc) # Params is now an instance variable so it should be passed thru different methods instance_variable_set("@#{element}", params) if store # pre rendering processor params = particle_pre(element, params, &user_proc) # we create a proc holder of any new particle if user pass a bloc particle_callback(element) store_proc(element, params, &user_proc) if user_proc render(element, params, &user_proc) if rendering # broadcasting(element) # post rendering processor params = particle_post(element, params, &user_proc) instance_variable_set("@#{element}", params) if store # post storage processor particle_after(element, params, &user_proc) # self end def inspect filtered_vars = instance_variables.reject { |var| var == :@html_object || var == :@history } content = filtered_vars.map do |var| "#{var}=#{instance_variable_get(var).inspect}" end.join(", ") "#<#{self.class}: #{content}>" end end