Module: Genesis

Includes:
GenesisHelper, GenesisKernel
Included in:
Atome
Defined in:
lib/atome/kernel/generators/genesis.rb

Overview

main entry for genesis

Class Method Summary collapse

Methods included from GenesisKernel

#additional_atomes, #create_new_atomes, #get_new_atome, #get_new_particle, #new_atome, #new_particle, #set_new_atome, #set_new_particle

Methods included from GenesisHelper

#broadcaster, #history

Class Method Details

.additional_atome_methods(method_name) ⇒ Object



127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/atome/kernel/generators/genesis.rb', line 127

def self.additional_atome_methods(method_name)
  # here is the pluralized
  Atome.define_method "#{method_name}s" do |params = nil|
    additional_atomes(method_name, params)
  end
  # here is the fast methods
  Atome.define_method "set_#{method_name}" do |params = nil, &proc|
    set_new_atome(method_name, params, proc)
  end
  Atome.define_method "get_#{method_name}" do
    get_new_atome(method_name)
  end
end

.additional_particle_methods(method_name) ⇒ Object



157
158
159
160
161
162
163
164
165
166
# File 'lib/atome/kernel/generators/genesis.rb', line 157

def self.additional_particle_methods(method_name)
  # here is the fast methods
  Atome.define_method "set_#{method_name}" do |params, &proc|
    set_new_particle(method_name, params, &proc)
  end

  Atome.define_method "get_#{method_name}" do
    get_new_particle(method_name)
  end
end

.atome_creator(method_name, &proc) ⇒ Object

we create the easy methods here : ¬



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/atome/kernel/generators/genesis.rb', line 142

def self.atome_creator(method_name, &proc)
  instance_exec(&proc) if proc.is_a?(Proc)
  # we add the new method to the atome's collection of methods
  Utilities.atomes(method_name)
  # we define many methods : easy, method=,pluralised and the fasts one, here is the easy
  Atome.define_method method_name do |params = nil, &user_proc|
    new_atome(method_name, params, user_proc)
  end
  # no we also add the method= for easy setting
  define_method("#{method_name}=") do |params, &user_proc|
    new_atome(method_name, params, user_proc)
  end
  additional_atome_methods(method_name)
end

.atome_creator_option(property_name, &proc) ⇒ Object



117
118
119
# File 'lib/atome/kernel/generators/genesis.rb', line 117

def self.atome_creator_option(property_name, &proc)
  @optionals_methods[property_name] = proc
end

.default_valueObject



109
110
111
# File 'lib/atome/kernel/generators/genesis.rb', line 109

def self.default_value
  { render: [:html] }
end

.particle_creator(method_name, &proc) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/atome/kernel/generators/genesis.rb', line 168

def self.particle_creator(method_name, &proc)
  instance_exec(&proc) if proc.is_a?(Proc)
  # we add the new method to the particle's collection of methods
  Utilities.particles(method_name)
  Atome.define_method method_name do |params = nil, &user_proc|
    new_particle(method_name, params, user_proc)
  end
  # no we also add the method= for easy setting
  define_method("#{method_name}=") do |params, &user_proc|
    new_particle(method_name, params, user_proc)
  end
  additional_particle_methods(method_name)
end

.run_optional_methods_helper(method_name) ⇒ Object



121
122
123
124
125
# File 'lib/atome/kernel/generators/genesis.rb', line 121

def self.run_optional_methods_helper(method_name)
  proc = nil
  proc = @optionals_methods[method_name] if @optionals_methods
  instance_exec(&proc) if proc.is_a?(Proc)
end