lib/atome/helpers/utilities.rb in atome-0.5.6.1.1 vs lib/atome/helpers/utilities.rb in atome-0.5.6.1.4
- old
+ new
@@ -8,24 +8,19 @@
def file_handler(parent, content, bloc)
grab(parent).instance_exec(content, &bloc)
end
-
-
def controller_sender(message)
return if $host == :html
json_msg = message.to_json
js_json_msg = json_msg.inspect
js_command = "atomeJS.controller_sender(#{js_json_msg})"
JS.eval(js_command)
end
-
-
-
# def global_monitoring(instance, methods_to_monitor, variables_to_monitor)
# methods_to_monitor.each do |methode|
# original_method = instance.method(methode)
# instance.define_singleton_method(methode) do |*args, &block|
# value_before = instance.instance_variable_get("@#{methode}")
@@ -53,11 +48,10 @@
# end
# end
end
-
def help(particle, &doc)
if doc
Universe.set_help(particle, &doc)
else
doc_found = Universe.get_help(particle)
@@ -72,11 +66,10 @@
example_found = Universe.get_example(particle)
instance_exec(&example_found) if example_found.is_a?(Proc)
end
end
-
# local server messaging
def file_for_opal(parent, bloc)
JS.eval("fileForOpal('#{parent}', #{bloc})")
end
@@ -284,14 +277,14 @@
instance_exec(val, &proc) if proc.is_a?(Proc)
end
end
def each_with_index(&proc)
- index=0
+ index = 0
collect.each do |val|
- instance_exec(val,index, &proc) if proc.is_a?(Proc)
- index+=1
+ instance_exec(val, index, &proc) if proc.is_a?(Proc)
+ index += 1
end
end
def <<(item)
collect << item
@@ -339,22 +332,26 @@
# we delete the parent (the layout) if it no more children attached
if parent_found.attached.length == 0
parent_found.delete(true)
end
end
- def server(server_params=nil)
+
+ def server(server_params = nil)
if server_params
- @current_server= server_params
+ @current_server = server_params
else
@current_server
end
end
def init_websocket
connection(server)
end
+ def init_database # this method is call from JS (atome/communication)
+ message({action: :init_db, value: {atome: {}, particles: {}} })
+ end
end