Module: EventBus::SingletonMixin

Includes:
BusMixin
Included in:
Singleton, Test02::UserService
Defined in:
lib/ls4/lib/ebus.rb

Defined Under Namespace

Classes: ConnectEntry

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from DeclarerBase::Methods

#ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from DeclarerBase

#call_slot, #signal_slot

Class Method Details

.extended(mod) ⇒ Object



268
269
270
271
272
# File 'lib/ls4/lib/ebus.rb', line 268

def self.extended(mod)
	mod.instance_eval do
		include ::Singleton
	end
end

Instance Method Details

#ebus_bind!Object Also known as: bind!



304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/ls4/lib/ebus.rb', line 304

def ebus_bind!
	constants.each {|const|
		if const.to_s =~ /^EBUS_CONNECT_.*/
			e = const_get(const)
			if e.bus.is_a?(Symbol)
				bus = eval("#{e.bus}")
			else
				bus = e.bus
			end
			bus.__send__("connect_#{e.slot}", instance.method(e.mname))
		end
	}
	self
end

#ebus_connect(bus, *slots) ⇒ Object Also known as: connect



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/ls4/lib/ebus.rb', line 285

def ebus_connect(bus, *slots)
	slots.each {|slot|
		case slot
		when Symbol
			ebus_connect_const_set(bus, slot, slot)
		when String
			ebus_connect_const_set(bus, slot.to_sym, slot.to_sym)
		when Hash
			slot.each_pair {|k,v|
				ebus_connect_const_set(bus, k.to_sym, v.to_sym)
			}
		else
			raise "slot name must be a Symbol: #{slot.inspect}"
		end
	}
end