custom_rails_settings_cached 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -5
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/lib/custom_rails_settings_cached.rb +6 -1
- data/lib/custom_rails_settings_cached/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17327ed70c7e7ba8ddad8ee0d098985f678dc0b46932531f3d87d4e0bcd10dae
|
4
|
+
data.tar.gz: 93d282446db83f79f3290f493545affa6daf5e4189c74db23c8221c65940d7c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a040b850d4d53c675680fcb870d1f266eef2e169b3ad87266a20cb6a39b5223a4b0a9032d9eedddc55596007b3e4b659abb43d55a42e31e712f8271543e4a5dd
|
7
|
+
data.tar.gz: 78fabfc6880a7e55a44264849b448de1eba16d44d37b7df1e18be4e0c820b24137a746329db0d7abb09be29c14d1570544dc5985d825253141476a04e51e665e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
## [
|
2
|
-
|
3
|
-
## [
|
4
|
-
|
5
|
-
|
1
|
+
## [v0.1.2]
|
2
|
+
- Support with default setting value in config/app.yml
|
3
|
+
## [v0.1.1]
|
4
|
+
- Support mixin Symbol, Hash both with CUSTOM_RAILS_SETTINGS_KEYS
|
5
|
+
## [v0.1.0]
|
6
|
+
- Custom rails setting cached with CUSTOM_RAILS_SETTINGS_KEYS
|
7
|
+
- Define accessor methods base on CUSTOM_RAILS_SETTINGS_KEYS
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,14 @@ Must define `CUSTOM_RAILS_SETTINGS_KEYS` before `include CustomRailsSettingsCach
|
|
43
43
|
google_analytics: :tracking_code,
|
44
44
|
facebook_pixel_ads: [:enabled, :tracking_code]
|
45
45
|
}
|
46
|
+
|
47
|
+
# Or mixin
|
48
|
+
|
49
|
+
CUSTOM_RAILS_SETTINGS_KEYS = {
|
50
|
+
:title, :description,
|
51
|
+
google_analytics: [:enabled, :tracking_code],
|
52
|
+
facebook_pixel_ads: [:enabled, :tracking_code]
|
53
|
+
}
|
46
54
|
```
|
47
55
|
Then, include `CustomRailsSettingsCached` in your model.
|
48
56
|
Exam:
|
@@ -12,7 +12,7 @@ module CustomRailsSettingsCached
|
|
12
12
|
def get_settings(name)
|
13
13
|
if has_associations_with_rails_settings
|
14
14
|
st = settings.find_by var: setting_key(name)
|
15
|
-
st
|
15
|
+
st ? st.value : default_value(name)
|
16
16
|
else
|
17
17
|
Setting[setting_key(name)]
|
18
18
|
end
|
@@ -51,6 +51,11 @@ module CustomRailsSettingsCached
|
|
51
51
|
@has_rails_settings = associations.any? { |a| a.name == :settings }
|
52
52
|
end
|
53
53
|
|
54
|
+
def default_value(name)
|
55
|
+
default_setting_key = "#{self.class.name.to_s.underscore}.#{name.to_s.underscore}"
|
56
|
+
Setting[default_setting_key]
|
57
|
+
end
|
58
|
+
|
54
59
|
if defined?(self::CUSTOM_RAILS_SETTINGS_KEYS)
|
55
60
|
build_custom_settings_methods self::CUSTOM_RAILS_SETTINGS_KEYS
|
56
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom_rails_settings_cached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: My custom with Rails Settings Cached
|
14
14
|
email:
|