Module: ObjectExtension

Included in:
Object
Defined in:
lib/atome/extensions/atome.rb

Instance Method Summary collapse

Instance Method Details

#new(params, &bloc) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/atome/extensions/atome.rb', line 7

def new(params, &bloc)
  # Genesis = Genesis.Genesis
  if params.key?(:atome)
    Universe.add_atomes_specificities params[:atome]
    Genesis.build_atome(params[:atome], &bloc)
    # end
  elsif params.key?(:particle)
    if Universe.particle_list[params[:particle]]
      puts "particle #{params[:particle]} already exist you can't create it"
    else
      Atome.instance_variable_set("@main_#{params[:particle]}", bloc)
      # render indicate if the particle needs to be rendered
      # store tell the system if it need to store the particle value
      # type help the system what type of type the particle will receive and store
      Genesis.build_particle(params[:particle], { render: params[:render], return: params[:return],
                                                  store: params[:store], type: params[:type],
                                                  category: params[:category] }, &bloc)
    end
  elsif params.key?(:sanitizer)
    Genesis.build_sanitizer(params[:sanitizer], &bloc)
  elsif params.key?(:pre)
    Atome.instance_variable_set("@pre_#{params[:pre]}", bloc)
  elsif params.key?(:post)
    Atome.instance_variable_set("@post_#{params[:post]}", bloc)
  elsif params.key?(:after)
    Atome.instance_variable_set("@after_#{params[:after]}", bloc)
  elsif params.key?(:initialized)
    Atome.initialized[params[:initialized]] = bloc
  elsif params.key?(:read)
    Atome.instance_variable_set("@read_#{params[:read]}", bloc)
  elsif params[:renderer]
    renderer_found = params[:renderer]
    if params[:specific]
      Universe.set_atomes_specificities(params)
      params[:specific] = "#{params[:specific]}_"
    end
    render_method = "#{renderer_found}_#{params[:specific]}#{params[:method]}"
    Genesis.build_render(render_method, &bloc)
  elsif params.key?(:molecule)
    molecule = params[:molecule]
    Genesis.build_molecule(molecule, &bloc)
    Universe.add_to_molecule_list(molecule)
  elsif params.key?(:tool)
    # we only store tools definition in the universe so it can be instanced using "A.build_tool" method when needed
    tool_content = Atome.instance_exec(&bloc) if bloc.is_a?(Proc)
    Universe.tools[params[:tool]] = tool_content
    # Universe.tools[params[:tool]]=bloc
  elsif params.key?(:template)
    A.build_template(&bloc)
  elsif params.key?(:code)
    A.build_code(&bloc)
  elsif params.key?(:test)
    A.build_test(&bloc)
  elsif params.key?(:preset)
    Atome.preset_builder(params[:preset], &bloc)
  end
  super if defined?(super)
end