has_setting 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/has_setting/ar_extensions.rb +7 -1
- data/lib/has_setting/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 628241cce8245e1e0d2d76bb35fb4bc33e6e00bc
|
4
|
+
data.tar.gz: 38e4e899954422e7a23a6ec786f877c7a1702e6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85f62ddf97adb6282b0e3347965c5411d7489534ccd026d4317e6d3a54c210b4bb77a7d159c706b0da7f9ae663808c7bbd7512a179aa63bb79990d0d4a463125
|
7
|
+
data.tar.gz: 1e2a0f35a9e60f32c0db6052447a6f7f17ab467623855d6fba20359c055be4aeee3ef368b1aadd3ad4b5c6a177cb6d5d0bcfa71fb85a4074025975f6889ebffe
|
@@ -34,6 +34,7 @@ module HasSetting
|
|
34
34
|
# default options
|
35
35
|
type = options[:type] || :string # treat as string
|
36
36
|
options[:localize] ||= false
|
37
|
+
options[:no_fallback] ||= false
|
37
38
|
self.has_setting_options[name] = options
|
38
39
|
|
39
40
|
# setter
|
@@ -69,7 +70,7 @@ module HasSetting
|
|
69
70
|
# only once
|
70
71
|
locale = localize?(name) ? I18n.locale.to_s : ""
|
71
72
|
s = self.settings.detect() {|item| item.name == name and item.locale.to_s == locale} # first see if there is a setting with current locale
|
72
|
-
s ||= self.settings.detect() {|item| item.name == name} # then if not found, take the first setting with matching name (TODO: add locale fallbacks)
|
73
|
+
s ||= self.settings.detect() {|item| item.name == name} unless no_fallback?(name) # then if not found, take the first setting with matching name (TODO: add locale fallbacks)
|
73
74
|
s
|
74
75
|
end
|
75
76
|
|
@@ -78,6 +79,11 @@ module HasSetting
|
|
78
79
|
options ? options[:localize] : false
|
79
80
|
end
|
80
81
|
|
82
|
+
def no_fallback? name
|
83
|
+
options = has_setting_option name
|
84
|
+
options ? options[:no_fallback] : false
|
85
|
+
end
|
86
|
+
|
81
87
|
def has_setting_option name
|
82
88
|
klass = self.class
|
83
89
|
option = klass.has_setting_options ? klass.has_setting_options[name] : nil
|
data/lib/has_setting/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_setting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simplificator GmbH
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Stores settings as key/value pairs in a settings table and provides accessors
|
15
15
|
for them on the owning object
|
@@ -20,7 +20,7 @@ executables: []
|
|
20
20
|
extensions: []
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
|
-
- .gitignore
|
23
|
+
- ".gitignore"
|
24
24
|
- README.md
|
25
25
|
- Rakefile
|
26
26
|
- VERSION.yml
|
@@ -43,22 +43,22 @@ licenses: []
|
|
43
43
|
metadata: {}
|
44
44
|
post_install_message:
|
45
45
|
rdoc_options:
|
46
|
-
- --charset=UTF-8
|
46
|
+
- "--charset=UTF-8"
|
47
47
|
require_paths:
|
48
48
|
- lib
|
49
49
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
56
|
-
- -
|
56
|
+
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
60
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
61
|
+
rubygems_version: 2.5.1
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Simple setting extension to AR
|