rails-settings-cached 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -16
- data/lib/rails-settings-cached.rb +1 -1
- data/lib/rails-settings/settings.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daf5a00211e61520780dfc7d4338b0bfdfc78c8d
|
4
|
+
data.tar.gz: b1838dd8e967045fdc6f607e0e9187bb2ee07827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67be845df66559b6167107af09b374a317661cf6e8a21529583afe4992f1797355c34900f0b72bf987644e6d3f7bfd2142c4253a073208e24935f53ade8e7530
|
7
|
+
data.tar.gz: 1a24510a42e87e3e3f33152e5a6a3f71ac9a08f1df6be853e42b622bf358acfdc17123a1ba443c6d5f8e54080552e13b6b3c2ca31039ca0ea2af449eb3d38780
|
data/README.md
CHANGED
@@ -9,7 +9,8 @@ arrays, or any object. Ported to Rails 3!
|
|
9
9
|
|
10
10
|
## Status
|
11
11
|
|
12
|
-
[](https://rubygems.org/gems/rails-settings-cached)
|
13
|
+
- [](http://travis-ci.org/huacnlee/rails-settings-cached)
|
13
14
|
|
14
15
|
## Setup
|
15
16
|
|
@@ -17,7 +18,7 @@ Edit your Gemfile:
|
|
17
18
|
|
18
19
|
```ruby
|
19
20
|
# Rails 4+
|
20
|
-
gem "rails-settings-cached", "0.3.
|
21
|
+
gem "rails-settings-cached", "0.3.1"
|
21
22
|
# Rails 3.x
|
22
23
|
gem "rails-settings-cached", "0.2.4"
|
23
24
|
```
|
@@ -37,7 +38,7 @@ end
|
|
37
38
|
```
|
38
39
|
|
39
40
|
Now just put that migration in the database with:
|
40
|
-
|
41
|
+
|
41
42
|
```bash
|
42
43
|
rake db:migrate
|
43
44
|
```
|
@@ -83,8 +84,8 @@ Setting.foo # returns nil
|
|
83
84
|
Want a list of all the settings?
|
84
85
|
|
85
86
|
```ruby
|
86
|
-
Setting.all
|
87
|
-
# returns {'admin_password' => 'super_secret', 'date_format' => '%m %d, %Y'}
|
87
|
+
Setting.all
|
88
|
+
# returns {'admin_password' => 'super_secret', 'date_format' => '%m %d, %Y'}
|
88
89
|
```
|
89
90
|
|
90
91
|
You need name spaces and want a list of settings for a give name space? Just choose your prefered named space delimiter and use Setting.all like this:
|
@@ -93,7 +94,7 @@ You need name spaces and want a list of settings for a give name space? Just cho
|
|
93
94
|
Setting['preferences.color'] = :blue
|
94
95
|
Setting['preferences.size'] = :large
|
95
96
|
Setting['license.key'] = 'ABC-DEF'
|
96
|
-
Setting.all('preferences.')
|
97
|
+
Setting.all('preferences.')
|
97
98
|
# returns { 'preferences.color' => :blue, 'preferences.size' => :large }
|
98
99
|
```
|
99
100
|
|
@@ -105,7 +106,7 @@ with the following:
|
|
105
106
|
Setting.defaults[:some_setting] = 'footastic'
|
106
107
|
Setting.where(:var => "some_setting").count
|
107
108
|
=> 0
|
108
|
-
Setting.some_setting
|
109
|
+
Setting.some_setting
|
109
110
|
=> "footastic"
|
110
111
|
```
|
111
112
|
|
@@ -115,18 +116,16 @@ Init defualt value in database, this has indifferent with `Setting.defaults[:som
|
|
115
116
|
Setting.save_default(:some_key, "123")
|
116
117
|
Setting.where(:var => "some_key").count
|
117
118
|
=> 1
|
118
|
-
Setting.some_key
|
119
|
+
Setting.some_key
|
119
120
|
=> "123"
|
120
121
|
```
|
121
|
-
|
122
|
-
|
123
122
|
|
124
123
|
Settings may be bound to any existing ActiveRecord object. Define this association like this:
|
125
124
|
Notice! is not do caching in this version.
|
126
|
-
|
125
|
+
|
127
126
|
```ruby
|
128
127
|
class User < ActiveRecord::Base
|
129
|
-
include RailsSettings::Extend
|
128
|
+
include RailsSettings::Extend
|
130
129
|
end
|
131
130
|
```
|
132
131
|
|
@@ -142,16 +141,16 @@ user.settings.all # { "color" => :red }
|
|
142
141
|
I you want to find users having or not having some settings, there are named scopes for this:
|
143
142
|
|
144
143
|
```ruby
|
145
|
-
User.with_settings
|
144
|
+
User.with_settings
|
146
145
|
# => returns a scope of users having any setting
|
147
146
|
|
148
|
-
User.with_settings_for('color')
|
147
|
+
User.with_settings_for('color')
|
149
148
|
# => returns a scope of users having a 'color' setting
|
150
149
|
|
151
|
-
User.without_settings
|
150
|
+
User.without_settings
|
152
151
|
# returns a scope of users having no setting at all (means user.settings.all == {})
|
153
152
|
|
154
|
-
User.without_settings('color')
|
153
|
+
User.without_settings('color')
|
155
154
|
# returns a scope of users having no 'color' setting (means user.settings.color == nil)
|
156
155
|
```
|
157
156
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-settings-cached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Squeegy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 4.0.0
|
22
|
+
version: 4.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.0.0
|
29
|
+
version: 4.0.0
|
30
30
|
description:
|
31
31
|
email: huacnlee@gmail.com
|
32
32
|
executables: []
|
@@ -71,3 +71,4 @@ summary: This is imporved from rails-settings, added caching. Settings is a plug
|
|
71
71
|
into your rails app. You can store any kind of object. Strings, numbers, arrays,
|
72
72
|
or any object. Ported to Rails 3!
|
73
73
|
test_files: []
|
74
|
+
has_rdoc:
|