This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 0e5c4440e8dbf03a8a008afe22332387080a2c32
tree df2b66851e53c2a24a3a763ff84a926a1c20e009
parent e259ac022230cab41a957a3e29de9c7cd3ae6c41
tree df2b66851e53c2a24a3a763ff84a926a1c20e009
parent e259ac022230cab41a957a3e29de9c7cd3ae6c41
| name | age | message | |
|---|---|---|---|
| |
.DS_Store | ||
| |
MIT-LICENSE | ||
| |
README.textile | ||
| |
Rakefile | ||
| |
init.rb | ||
| |
install.rb | ||
| |
lib/ | ||
| |
spec/ | ||
| |
tasks/ | ||
| |
uninstall.rb |
README.textile
ActsAsConfigurable
Rails plugin that adds dynamic (non-database) configuration to any ActiveRecord model.
Examples
Basic usage:
class User < ActiveRecord::Base
acts_as_configurable
configuration do |config|
config.passwords.min_length = 6
config.passwords.max_length = 12
end
end
And then to access that configuration, simply call:
$> User.configuration
$> => {:passwords => { :min_length => 6, :max_length => 12 }}
Or just keep going down the chain to get to the specifics:
$> User.configuration.passwords
$> => {:min_length => 6, :max_length => 12}
$> User.configuration.passwords.min_length
$> => 6
Now, granted that a “configuration” class method is common enough that there may be a case
where you have a conflict. Well, you can also configure that part:
class User < ActiveRecord::Base
acts_as_configurable :with => :settings
settings do |setting|
setting.passwords.min_length = 6
setting.passwords.max_length = 12
end
end
Then just use “settings” in place of “configuration” when accessing the data.
$> User.settings.passwords
$> => {:min_length => 6, :max_length => 12}
© 2008 Ryan Heath and Chris Scharf, released under the MIT license








