Named Configuration Helper
Reported by Matt Todd | April 29th, 2008 @ 10:27 PM | in Release 0.5.0
We should be able to specify something like:
Halcyon.configurable :db
which should make the following possible:
Halcyon.db = {:foo => "bar"}
Halcyon.db[:foo]
It should also make sure that it calles to_mash
on Hash-like content (well, they could want a configuration setting as an Array).
This would clean up the need for writing like this:
Halcyon.config[:db] = {:foo => "bar"}
Halcyon.config[:db][:foo]
Should probably supply with something similar to this for non-configuration accessors (which effectively provides a publicly exposed API for attr_accessor
with a few niceties). For example:
# Queue Server Config
Halcyon.accessor :qsc, initial_value do |new_incoming_value|
@qsc = new_incoming_value.to_mash
end
That's one of the most complex examples, but can be useful to process incoming data to normalize data, etc. Here, we make sure data has to_mash
called on it, and the configurable
accessor would make more sense for this, but this is a sample... it could be useful to actually create the instance of the DB as a property of Halcyon.db
etc.
Leave off the block for straight-up assignment like a normal attr_accessor
would. Also, the initial value is unnecessary (nil
is a perfectly legitimate default value).
Comments and changes to this ticket
-
Matt Todd May 8th, 2008 @ 05:55 AM
- State changed from new to resolved
Implemented the
Halcyon.configurable_attr
accessor, along with tests.Still considering the idea of
Halcyon.accessor
but closing this ticket. Open another ticket specifically for that feature for 0.5.1 or 0.6.0 for consideration.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.