has_setting 0.7.3 → 0.7.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c320931c608eaeac7b2134bd75561e57932a6cf8
4
- data.tar.gz: 8b7b9a8993158a8b1ef7e584f5b63471c71a7649
3
+ metadata.gz: 628241cce8245e1e0d2d76bb35fb4bc33e6e00bc
4
+ data.tar.gz: 38e4e899954422e7a23a6ec786f877c7a1702e6d
5
5
  SHA512:
6
- metadata.gz: e83389a8001fd0906c1c0e53f8a4ed605115a29998d3f6c6d9f21075137f2a733707495c47fde702ce21683e0b0edfbdfa21c7bcf859ae7f12f7493c4da33f36
7
- data.tar.gz: 602429b6032d14d649ac29f87f3885c4c678fdc4f7853e2460ec21aaa47344ac593f5963cbec60ea37f8fed8d6dd88a4a080c5b880334bb7530f67f1bef36813
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
@@ -1,3 +1,3 @@
1
1
  module HasSetting
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
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.3
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: 2013-06-20 00:00:00.000000000 Z
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.0.3
61
+ rubygems_version: 2.5.1
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Simple setting extension to AR