configurable_engine 0.3.0 → 0.3.1
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 +6 -14
- data/.document +5 -0
- data/.gitignore +43 -0
- data/.rspec +1 -0
- data/.travis.yml +18 -0
- data/Gemfile +2 -7
- data/Gemfile.lock +160 -54
- data/Rakefile +12 -39
- data/app/models/configurable.rb +36 -5
- data/app/views/admin/configurables/show.html.erb +1 -1
- data/config/cucumber.yml +8 -0
- data/configurable_engine.gemspec +22 -65
- data/features/admin_configurables.feature +10 -0
- data/features/step_definitions/web_steps.rb +219 -0
- data/features/support/env.rb +57 -0
- data/features/support/paths.rb +35 -0
- data/gemfiles/Gemfile.base +24 -0
- data/gemfiles/Gemfile.rails3_1 +2 -0
- data/gemfiles/Gemfile.rails3_1.lock +180 -0
- data/gemfiles/Gemfile.rails4_0 +2 -0
- data/gemfiles/Gemfile.rails4_0.lock +175 -0
- data/lib/configurable_engine/configurables_controller.rb +5 -4
- data/lib/configurable_engine/engine.rb +4 -0
- data/lib/configurable_engine/version.rb +3 -0
- data/spec/dummy/.gitignore +4 -0
- data/spec/dummy/README +256 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +13 -0
- data/spec/dummy/config/configurable.yml +27 -0
- data/spec/dummy/config/database.yml +29 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +51 -0
- data/spec/dummy/config/environments/test.rb +85 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/migrate/20110110001344_create_configurables.rb +17 -0
- data/spec/dummy/db/schema.rb +25 -0
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/lib/tasks/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/rails.png +0 -0
- data/spec/dummy/public/index.html +239 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/vendor/plugins/.gitkeep +0 -0
- data/spec/models/configurable_spec.rb +134 -0
- data/spec/spec_helper.rb +27 -0
- data/tasks/cucumber.rake +56 -0
- metadata +120 -83
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZGE5NWNkYWE4MzQ1YjkzYWNiZmQwODFiMzJkZGZjMjQ2ODQ3NTU4MjA0YWE2
|
10
|
-
Y2I1MDM1N2UzMTM4MGY0NzcwMGQ2YTdiYjk3N2MxZTRlZDRjZDI4ZmQ1MDBj
|
11
|
-
Zjc2ZThlMjYwOThhMTliM2YwZDkyMzc5MjAyNzdkYjhjN2EwMjA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
N2Y0MWEyNTMxODI4MDBiNjgyNTM2NWQ3Y2I3Y2ViNWNlZTVmODRjNzI0ZjZl
|
14
|
-
YjMxYzcxNTQzODBmMWVmMDQ3ZmU2ODUxYjFiZDJkMWU1ZWU2N2VkZjFiOTg1
|
15
|
-
ZTNiMjcxMjk4NmYwYWZlZWMxNDAxZGQ5YzZmMDEyMzlmNzQ0NTc=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cb3a943a784294cf89013a42e8f31eaa51ca79be
|
4
|
+
data.tar.gz: 5269001890ee44f5f7af4c01be487fd11ee19242
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea7eadc32bab5381d3ff5d37d4046d7651ca42efa2f8cdfd25b7bb94bd52ba2791b2cad44f76e8d7f78d9576adf8894658a4226f6f09bce8949ee2c27072604c
|
7
|
+
data.tar.gz: 1cdaad24d66960ac916dad4398d9c21055fdb4c5775c67aad36e5388ada409aa56eec7b67c697ac6a7753380d5b2c5d80b4cfed4d840662bdb6118d5ae54c68a
|
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
#
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
#
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
#
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
.rvmrc
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
- 1.9.3
|
5
|
+
- jruby-19mode
|
6
|
+
env:
|
7
|
+
- DB=sqlite
|
8
|
+
- DB=mysql
|
9
|
+
- DB=postgresql
|
10
|
+
gemfile:
|
11
|
+
- Gemfile
|
12
|
+
- gemfiles/Gemfile.rails3_1
|
13
|
+
- gemfiles/Gemfile.rails4_0
|
14
|
+
before_script:
|
15
|
+
- mysql -e 'create database strano_test'
|
16
|
+
- psql -c 'create database strano_test' -U postgres
|
17
|
+
- RAILS_ENV=test rake app:db:migrate
|
18
|
+
- rake app:db:test:prepare
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,72 +1,178 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
actionmailer (3.2.17)
|
5
|
+
actionpack (= 3.2.17)
|
6
|
+
mail (~> 2.5.4)
|
7
|
+
actionpack (3.2.17)
|
8
|
+
activemodel (= 3.2.17)
|
9
|
+
activesupport (= 3.2.17)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.4)
|
13
|
+
rack (~> 1.4.5)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.2.1)
|
17
|
+
activemodel (3.2.17)
|
18
|
+
activesupport (= 3.2.17)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.17)
|
21
|
+
activemodel (= 3.2.17)
|
22
|
+
activesupport (= 3.2.17)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activerecord-jdbc-adapter (1.3.6)
|
26
|
+
activerecord (>= 2.2)
|
27
|
+
activerecord-jdbcmysql-adapter (1.3.6)
|
28
|
+
activerecord-jdbc-adapter (~> 1.3.6)
|
29
|
+
jdbc-mysql (>= 5.1.22)
|
30
|
+
activerecord-jdbcpostgresql-adapter (1.3.6)
|
31
|
+
activerecord-jdbc-adapter (~> 1.3.6)
|
32
|
+
jdbc-postgres (>= 9.1)
|
33
|
+
activerecord-jdbcsqlite3-adapter (1.3.6)
|
34
|
+
activerecord-jdbc-adapter (~> 1.3.6)
|
35
|
+
jdbc-sqlite3 (~> 3.7.2)
|
36
|
+
activeresource (3.2.17)
|
37
|
+
activemodel (= 3.2.17)
|
38
|
+
activesupport (= 3.2.17)
|
39
|
+
activesupport (3.2.17)
|
40
|
+
i18n (~> 0.6, >= 0.6.4)
|
41
|
+
multi_json (~> 1.0)
|
42
|
+
arel (3.0.3)
|
43
|
+
bouncy-castle-java (1.5.0147)
|
44
|
+
builder (3.0.4)
|
45
|
+
capybara (2.2.1)
|
46
|
+
mime-types (>= 1.16)
|
47
|
+
nokogiri (>= 1.3.3)
|
48
|
+
rack (>= 1.0.0)
|
49
|
+
rack-test (>= 0.5.4)
|
50
|
+
xpath (~> 2.0)
|
51
|
+
coderay (1.1.0)
|
52
|
+
cucumber (1.3.11)
|
7
53
|
builder (>= 2.1.2)
|
8
54
|
diff-lcs (>= 1.1.3)
|
9
|
-
gherkin (~> 2.12
|
55
|
+
gherkin (~> 2.12)
|
10
56
|
multi_json (>= 1.7.5, < 2.0)
|
11
57
|
multi_test (>= 0.0.2)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
58
|
+
cucumber-rails (1.4.0)
|
59
|
+
capybara (>= 1.1.2)
|
60
|
+
cucumber (>= 1.2.0)
|
61
|
+
nokogiri (>= 1.5.0)
|
62
|
+
rails (>= 3.0.0)
|
63
|
+
database_cleaner (1.2.0)
|
64
|
+
diff-lcs (1.2.5)
|
65
|
+
erubis (2.7.0)
|
66
|
+
ffi (1.9.3-java)
|
67
|
+
gherkin (2.12.2)
|
68
|
+
multi_json (~> 1.3)
|
69
|
+
gherkin (2.12.2-java)
|
16
70
|
multi_json (~> 1.3)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
71
|
+
hike (1.2.3)
|
72
|
+
i18n (0.6.9)
|
73
|
+
jdbc-mysql (5.1.28)
|
74
|
+
jdbc-postgres (9.3.1100)
|
75
|
+
jdbc-sqlite3 (3.7.2.1)
|
76
|
+
journey (1.0.4)
|
77
|
+
jruby-openssl (0.9.4)
|
78
|
+
bouncy-castle-java (>= 1.5.0147)
|
79
|
+
json (1.8.1)
|
80
|
+
json (1.8.1-java)
|
81
|
+
mail (2.5.4)
|
82
|
+
mime-types (~> 1.16)
|
83
|
+
treetop (~> 1.4.8)
|
84
|
+
method_source (0.8.2)
|
85
|
+
mime-types (1.25.1)
|
86
|
+
mini_portile (0.5.2)
|
87
|
+
multi_json (1.8.4)
|
88
|
+
multi_test (0.0.3)
|
89
|
+
mysql2 (0.3.15)
|
90
|
+
nokogiri (1.6.1)
|
91
|
+
mini_portile (~> 0.5.0)
|
92
|
+
nokogiri (1.6.1-java)
|
93
|
+
mini_portile (~> 0.5.0)
|
94
|
+
pg (0.17.1)
|
95
|
+
polyglot (0.3.4)
|
96
|
+
pry (0.9.12.6)
|
97
|
+
coderay (~> 1.0)
|
98
|
+
method_source (~> 0.8)
|
99
|
+
slop (~> 3.4)
|
100
|
+
pry (0.9.12.6-java)
|
101
|
+
coderay (~> 1.0)
|
102
|
+
method_source (~> 0.8)
|
103
|
+
slop (~> 3.4)
|
104
|
+
spoon (~> 0.0)
|
105
|
+
rack (1.4.5)
|
106
|
+
rack-cache (1.2)
|
107
|
+
rack (>= 0.4)
|
108
|
+
rack-ssl (1.3.3)
|
109
|
+
rack
|
110
|
+
rack-test (0.6.2)
|
111
|
+
rack (>= 1.0)
|
112
|
+
rails (3.2.17)
|
113
|
+
actionmailer (= 3.2.17)
|
114
|
+
actionpack (= 3.2.17)
|
115
|
+
activerecord (= 3.2.17)
|
116
|
+
activeresource (= 3.2.17)
|
117
|
+
activesupport (= 3.2.17)
|
30
118
|
bundler (~> 1.0)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
multi_test (0.0.2)
|
42
|
-
multi_xml (0.5.5)
|
43
|
-
multipart-post (1.2.0)
|
44
|
-
nokogiri (1.5.10)
|
45
|
-
oauth2 (0.9.2)
|
46
|
-
faraday (~> 0.8)
|
47
|
-
httpauth (~> 0.2)
|
48
|
-
jwt (~> 0.1.4)
|
49
|
-
multi_json (~> 1.0)
|
50
|
-
multi_xml (~> 0.5)
|
51
|
-
rack (~> 1.2)
|
52
|
-
rack (1.5.2)
|
53
|
-
rake (10.1.0)
|
54
|
-
rdoc (4.0.1)
|
119
|
+
railties (= 3.2.17)
|
120
|
+
railties (3.2.17)
|
121
|
+
actionpack (= 3.2.17)
|
122
|
+
activesupport (= 3.2.17)
|
123
|
+
rack-ssl (~> 1.3.2)
|
124
|
+
rake (>= 0.8.7)
|
125
|
+
rdoc (~> 3.4)
|
126
|
+
thor (>= 0.14.6, < 2.0)
|
127
|
+
rake (10.1.1)
|
128
|
+
rdoc (3.12.2)
|
55
129
|
json (~> 1.4)
|
56
|
-
rspec (2.14.
|
130
|
+
rspec-core (2.14.8)
|
131
|
+
rspec-expectations (2.14.5)
|
132
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
133
|
+
rspec-mocks (2.14.6)
|
134
|
+
rspec-rails (2.14.1)
|
135
|
+
actionpack (>= 3.0)
|
136
|
+
activemodel (>= 3.0)
|
137
|
+
activesupport (>= 3.0)
|
138
|
+
railties (>= 3.0)
|
57
139
|
rspec-core (~> 2.14.0)
|
58
140
|
rspec-expectations (~> 2.14.0)
|
59
141
|
rspec-mocks (~> 2.14.0)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
142
|
+
slop (3.4.7)
|
143
|
+
spoon (0.0.4)
|
144
|
+
ffi
|
145
|
+
sprockets (2.2.2)
|
146
|
+
hike (~> 1.2)
|
147
|
+
multi_json (~> 1.0)
|
148
|
+
rack (~> 1.0)
|
149
|
+
tilt (~> 1.1, != 1.3.0)
|
150
|
+
sqlite3 (1.3.9)
|
151
|
+
thor (0.18.1)
|
152
|
+
tilt (1.4.1)
|
153
|
+
treetop (1.4.15)
|
154
|
+
polyglot
|
155
|
+
polyglot (>= 0.3.1)
|
156
|
+
tzinfo (0.3.38)
|
157
|
+
xpath (2.0.0)
|
158
|
+
nokogiri (~> 1.3)
|
64
159
|
|
65
160
|
PLATFORMS
|
161
|
+
java
|
66
162
|
ruby
|
67
163
|
|
68
164
|
DEPENDENCIES
|
69
|
-
|
70
|
-
|
165
|
+
activerecord-jdbcmysql-adapter
|
166
|
+
activerecord-jdbcpostgresql-adapter
|
167
|
+
activerecord-jdbcsqlite3-adapter
|
168
|
+
capybara
|
169
|
+
cucumber-rails
|
170
|
+
database_cleaner
|
171
|
+
jruby-openssl
|
172
|
+
mysql2
|
173
|
+
pg
|
174
|
+
pry
|
175
|
+
rails (~> 3.2.0)
|
71
176
|
rake
|
72
|
-
rspec
|
177
|
+
rspec-rails
|
178
|
+
sqlite3
|
data/Rakefile
CHANGED
@@ -1,45 +1,18 @@
|
|
1
|
-
|
2
|
-
require 'bundler'
|
1
|
+
#!/usr/bin/env rake
|
3
2
|
begin
|
4
|
-
|
5
|
-
rescue
|
6
|
-
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
9
6
|
end
|
10
|
-
require 'rake'
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "configurable_engine"
|
16
|
-
gem.homepage = "http://github.com/paulca/configurable_engine"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{Database-backed configuration for Rails 3, with defaults from config file.}
|
19
|
-
gem.description = %Q{Configurable is a Rails 3 engine that allows you to set up config variables in a config file, specifying default values for all environments. These variables can then be set on a per-app basis using a user facing configuration screen. }
|
20
|
-
gem.email = "paul@rslw.com"
|
21
|
-
gem.authors = ["Paul Campbell"]
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
gem.add_runtime_dependency 'rails', '>3'
|
25
|
-
gem.add_runtime_dependency 'activerecord', '>3'
|
26
|
-
gem.files = FileList["[A-Za-z]*", "lib/**/*", "app/**/*", "config/*"]
|
27
|
-
end
|
28
|
-
# Jeweler::RubygemsDotOrgTasks.new
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
29
10
|
|
30
|
-
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
13
|
+
# require 'rspec/core'
|
31
14
|
require 'rspec/core/rake_task'
|
32
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
-
end
|
35
|
-
|
36
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
37
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
38
|
-
spec.rcov = true
|
39
|
-
end
|
40
|
-
|
41
|
-
require 'cucumber/rake/task'
|
42
|
-
Cucumber::Rake::Task.new(:features)
|
43
|
-
|
44
|
-
task :default => :spec
|
45
15
|
|
16
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
17
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
18
|
+
task :default => [:spec, :cucumber]
|
data/app/models/configurable.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
class Configurable < ActiveRecord::Base
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
after_save :invalidate_cache, if: -> { ConfigurableEngine::Engine.config.use_cache }
|
4
|
+
|
5
|
+
validates_presence_of :name
|
6
|
+
validates_uniqueness_of :name
|
7
|
+
|
8
|
+
validate :type_of_value
|
5
9
|
|
6
10
|
def self.defaults
|
7
|
-
HashWithIndifferentAccess.new(
|
11
|
+
@defaults ||= HashWithIndifferentAccess.new(
|
8
12
|
YAML.load_file(
|
9
13
|
Rails.root.join('config', 'configurable.yml')
|
10
14
|
)
|
@@ -27,7 +31,15 @@ class Configurable < ActiveRecord::Base
|
|
27
31
|
def self.[](key)
|
28
32
|
return self.defaults[key][:default] unless table_exists?
|
29
33
|
|
30
|
-
value =
|
34
|
+
value = if ConfigurableEngine::Engine.config.use_cache
|
35
|
+
Rails.cache.fetch("configurable_engine:#{key}") {
|
36
|
+
find_by_name(key).try(:value)
|
37
|
+
}
|
38
|
+
else
|
39
|
+
find_by_name(key).try(:value)
|
40
|
+
end
|
41
|
+
|
42
|
+
value ||= self.defaults[key][:default]
|
31
43
|
case self.defaults[key][:type]
|
32
44
|
when 'boolean'
|
33
45
|
[true, 1, "1", "t", "true"].include?(value)
|
@@ -56,4 +68,23 @@ class Configurable < ActiveRecord::Base
|
|
56
68
|
end
|
57
69
|
end
|
58
70
|
|
59
|
-
|
71
|
+
private
|
72
|
+
|
73
|
+
def type_of_value
|
74
|
+
return unless name
|
75
|
+
case Configurable.defaults[name][:type]
|
76
|
+
when 'boolean'
|
77
|
+
[true, 1, "1", "true", false, 0, "0", "false"].include?(value)
|
78
|
+
when 'decimal'
|
79
|
+
Float(value) rescue errors.add(:value, I18n.t("activerecord.errors.messages.invalid"))
|
80
|
+
when 'integer'
|
81
|
+
Integer(value) rescue errors.add(:value, I18n.t("activerecord.errors.messages.invalid"))
|
82
|
+
when 'list'
|
83
|
+
value.is_a?(Array) rescue errors.add(:value, I18n.t("activerecord.errors.messages.invalid"))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def invalidate_cache
|
88
|
+
Rails.cache.delete("configurable_engine:#{self.name}")
|
89
|
+
end
|
90
|
+
end
|