03 Apr '12, 11pm

MyGem.configure block - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS:

MyGem.configure block - GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS:

January 20, 2010 Tagged: pattern ruby gem configuration Comments (View) MyGem.configure block We recently made some enhancements to Clearance . One of those was to replace a manual process of the developer setting constants in their Rails environment files with a configuration block that could be used in config/initializers/clearance.rb. I liked the way Hoptoad does it and wanted to implement the same pattern: HoptoadNotifier.configure do |config| config.api_key = 'your_key_here' end So let’s implement: module Clearance class << self attr_accessor :configuration end def self.configure self.configuration ||= Configuration.new yield(configuration) end class Configuration attr_accessor :mailer_sender def initialize @mailer_sender = '[email protected]' end end end We have a configure class method that stores a Configuration object inside the Clearance module. Anything app...

Full article: http://robots.thoughtbot.com/post/344833329/mygem-configu...

Tweets

New blogger on the block

anilnetto.com 03 Apr '12, 6pm

A long awaited entry into blogosphere: you would have seen his writings all over the place including his contributions to ...

Apache Block III helicopter performs well in te...

army.mil 04 Apr '12, 1pm

NASHVILLE, Tenn. (Army News Service, April 3, 2012) -- The U.S. Army's AH-64 Apache Block III next-generation attack helic...