Module: Wires

Defined in:
lib/wires/base.rb

Class Method Summary collapse

Class Method Details

.current_networkObject



27
28
29
# File 'lib/wires/base.rb', line 27

def self.current_network
  @current_network ||= network
end

.current_network_nameObject



23
24
25
# File 'lib/wires/base.rb', line 23

def self.current_network_name
  @networks.each_pair.select{ |k,v| v==@current_network }.first.first
end

.network(id = :main) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/wires/base.rb', line 8

def self.network(id=:main)
  @networks ||= {main:Wires}
  
  @networks[id] = Module.new \
    unless @networks.has_key? id
  @networks[id].const_set :Namespace, @networks[id] \
    unless @networks[id].const_defined? :Namespace
  
  return @networks[id]
end

.replicateObject



31
32
33
34
35
36
37
38
39
# File 'lib/wires/base.rb', line 31

def self.replicate
  save_name = Wires.current_network_name
  other = Wires.set_current_network Object.new
  
  load __FILE__
  
  Wires.set_current_network save_name
  return other
end

.set_current_network(*args) ⇒ Object



19
20
21
# File 'lib/wires/base.rb', line 19

def self.set_current_network(*args)
  @current_network = network(*args)
end