diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-03 03:31:31 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-03 03:31:31 -0700 |
commit | 99f998da87211b9bb5b3fa2a47ee1b2160eb1322 (patch) | |
tree | 28cf3389a295d7ed26e91e1f412d637ba1d7439f | |
parent | f154ff562cf0803a4435ddb89d42c46154225bc8 (diff) | |
download | rainbows-99f998da87211b9bb5b3fa2a47ee1b2160eb1322.tar.gz |
This should make it easier to maintain/read configs that are Rainbows-specific
-rw-r--r-- | lib/rainbows/configurator.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/rainbows/configurator.rb b/lib/rainbows/configurator.rb index 2fb42fe..1d25f9e 100644 --- a/lib/rainbows/configurator.rb +++ b/lib/rainbows/configurator.rb @@ -3,7 +3,16 @@ module Rainbows class Configurator < ::Unicorn::Configurator + # configures rainbows + def rainbows(&block) + block_given? or raise ArgumentError, "rainbows requires a block" + instance_eval(&block) + end + + private + def use(model) + assert_in_rainbows begin model = Rainbows.const_get(model) rescue NameError @@ -16,11 +25,21 @@ module Rainbows end def worker_connections(nr) + assert_in_rainbows (Integer === nr && nr > 0) || nr.nil? or raise ArgumentError, "worker_connections must be an Integer or nil" set[:worker_connections] = nr end + private + + def assert_in_rainbows # :nodoc: + c = caller + c.grep(/`rainbows'\z/).empty? and + raise ArgumentError, + "#{%r!`(\w+)'\z!.match(c.first)[1]} must be called in `rainbows'" + end + end end |