-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
46 lines (30 loc) · 1.06 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
RailsSettings
============
Right now this is only working for datamapper. I will try to port to ActiveRecord shortly
Enable settings for your app or models
Add the slice as a regular dependency
dependency 'rails-settings'
Create a model that will hold all settings. Include the following as a
basis. No other includes are necessary.
class Setting
include MerbSettings::Adapter::DataMapper
include MerbSettings::Adapter::DataMapper::DefaultModelSetup
end
This then enables you to do the following:
Setting.foo = "test"
Setting.bar = 9
Setting.foo #=> "test"
Setting.foo = 9
Setting.foo #=> 9
To have settings that are scoped to a model include the following alongside
all your other model code:
class User
include RailsSettings::ScopedMethods
property :foo, ....
setting :foo, 'text'
setting :bar, 12
end
Notice that you can also set defaults for some settings so that if they are
called upon before they are set then you will get the default (this actually
is not working yet :-) )
------------------------------------------------------------------------------