user_preferences 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Appraisals +4 -4
- data/CHANGELOG.md +5 -0
- data/gemfiles/rails_4.gemfile +1 -1
- data/gemfiles/{rails_3.gemfile → rails_5.gemfile} +1 -1
- data/lib/user_preferences/api.rb +2 -5
- data/lib/user_preferences/preference.rb +6 -2
- data/lib/user_preferences/preference_definition.rb +1 -1
- data/lib/user_preferences/version.rb +1 -1
- data/spec/user_preferences/api_spec.rb +1 -1
- data/spec/user_preferences/preference_spec.rb +1 -1
- data/user_preferences.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15615015e9ccb0efd6e0db7e176c1d13c8699d71
|
4
|
+
data.tar.gz: 9d62fe5e9b60512492121e22f93e0fa892ed1344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da8293ea1bbfd7cef25c5aa5ca68f77e3789f7e65e04651792f37a0a2e894dbb5c6f99962eaba85689c8be3437169628fc3f1bfd3e900459f6f347845431bb4c
|
7
|
+
data.tar.gz: e0017a948a1eafaad7e20f80fe9eadcf6d3ec1e81c11f610e661dcc9c011a172aa908bfd8dc0275d00492b190ad61b2fb3913d36b21db2aa3a1cea0c49f8c05d
|
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
data/gemfiles/rails_4.gemfile
CHANGED
data/lib/user_preferences/api.rb
CHANGED
@@ -18,6 +18,7 @@ module UserPreferences
|
|
18
18
|
hash.each do |name, value|
|
19
19
|
find_or_init_preference(name).update_value!(value)
|
20
20
|
end
|
21
|
+
reload
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -41,11 +42,7 @@ module UserPreferences
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def find_or_init_preference(name)
|
44
|
-
|
45
|
-
preference = @scope.find_by_name(name) || @scope.build(name: name, category: @category)
|
46
|
-
saved_preferences << preference
|
47
|
-
end
|
48
|
-
preference
|
45
|
+
@scope.find_or_initialize_by(name: name, category: @category)
|
49
46
|
end
|
50
47
|
|
51
48
|
def hash_setter(&block)
|
@@ -8,14 +8,18 @@ class UserPreferences::Preference < ActiveRecord::Base
|
|
8
8
|
delegate :binary?, :default, :permitted_values, :lookup, :to_db, to: :definition
|
9
9
|
|
10
10
|
def update_value!(v)
|
11
|
-
update_attributes!(value:
|
11
|
+
update_attributes!(value: v)
|
12
12
|
end
|
13
13
|
|
14
14
|
def value
|
15
15
|
lookup(attributes['value'])
|
16
16
|
end
|
17
17
|
|
18
|
+
def value=(v)
|
19
|
+
super(to_db(v))
|
20
|
+
end
|
21
|
+
|
18
22
|
def definition
|
19
23
|
UserPreferences[category, name]
|
20
24
|
end
|
21
|
-
end
|
25
|
+
end
|
data/user_preferences.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency 'activerecord', '>=
|
22
|
+
spec.add_dependency 'activerecord', '>= 4.0'
|
23
23
|
|
24
24
|
spec.add_development_dependency "appraisal"
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: user_preferences
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Dust
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: appraisal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,8 +111,8 @@ files:
|
|
111
111
|
- LICENSE.txt
|
112
112
|
- README.md
|
113
113
|
- Rakefile
|
114
|
-
- gemfiles/rails_3.gemfile
|
115
114
|
- gemfiles/rails_4.gemfile
|
115
|
+
- gemfiles/rails_5.gemfile
|
116
116
|
- lib/generators/user_preferences/install_generator.rb
|
117
117
|
- lib/generators/user_preferences/templates/migration.rb
|
118
118
|
- lib/generators/user_preferences/templates/user_preferences.yml
|
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
155
|
version: '0'
|
156
156
|
requirements: []
|
157
157
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.4.
|
158
|
+
rubygems_version: 2.4.5.1
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: User preferences gem for Rails.
|