01 Jan '14, 9am

Matz の 20 行 DI コンテナ。僕が作った Dee も大体似た実装になってます。 / “Project: MATZ-DI: Matz's Dep…” #matz #ruby #di

# Matz DI -- Block Injection # # Usage: # # def start_app # c = DI::Container.new # c.define(:blog) {|c| Blog.new(c.input, c.display)} # c.define(:input) {Input.new} # c.define(:dbms){DBMS.new} # c.define(:markup){Markup.new} # c.define(:plugin){|c| # p = Plugin.new # p.dbms = c.dbms # } # c.define(:display) {|c| # Display.new(c.dbms, c.markup, c.plugin) # } # blog = c.instance(:blog) # end module DI class Container def initialize @services = {} @instances = {} end def define(name, &block) @services[name] = block class << self self end .instance_eval { define_method(name) { self .instance(name) } } end def instance(name) return @instances[name] if @instances[name] @instances[name] = @services[name].call(self ) end end end

Full article: http://onestepback.org/articles/depinj/matz/matzdi_block_...

Tweets

USBPass – a Mooltipass-like Project

USBPass – a Mooltipass-like Project

hackaday.com 01 Jan '14, 3pm

A total of 20 passwords can be stored in the microcontroller’s memory, which can be ‘typed’ by the platform using the push...

"@olgaloversID: Coba di tebak ya Ababil bang @B...

twitter.com 04 Jan '14, 11am

To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content,...