Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

The loader will just not send key names but always use :[] and :[]= f…

…or safety.
  • Loading branch information...
commit d7315914efa5064beee76eeb4bd36653dd7480ab 1 parent 1f3343a
@metaskills authored
View
5 CHANGELOG
@@ -1,4 +1,9 @@
+= 3.2.4
+
+* The loader will just not send to key names but always use :[] and :[]= for safety.
+
+
= 3.2.3
* Allow inspect of the StoreConfigurable object to pass down to ordered options.
View
4 lib/store_configurable/object.rb
@@ -38,8 +38,8 @@ def load(yaml, owner)
config = StoreConfigurable::Object.new
config.__store_configurable_owner__ = owner
loader = lambda do |options, key, value|
- value.is_a?(Hash) ? value.each { |k,v| loader.call(options.send(key), k, v) } :
- options.send("#{key}=", value)
+ value.is_a?(Hash) ? value.each { |k,v| loader.call(options.send(:[],key), k, v) } :
+ options.send(:[]=, key, value)
end
stored_data.each { |k,v| loader.call(config, k, v) }
owner.changed_attributes.delete('_config')
View
2  lib/store_configurable/version.rb
@@ -1,6 +1,6 @@
module StoreConfigurable
# We track ActiveRecord's major and minor version and follow semantic versioning.
- VERSION = '3.2.3'
+ VERSION = '3.2.4'
end
View
12 test/cases/base_test.rb
@@ -57,6 +57,12 @@ class StoreConfigurable::BaseTest < StoreConfigurable::TestCase
lambda{ user_ken.config.merge({}) }.must_raise(NotImplementedError)
end
+ it 'can save unsafe keys' do
+ user_ken.config.sortable_tables[:posts][:sort].on = 'title'
+ user_ken.config.sortable_tables[:posts][:sort].dir = 'asc'
+ user_ken.save!
+ end
+
describe 'existing data' do
let(:color) { '#c1c1c1' }
@@ -150,6 +156,12 @@ class StoreConfigurable::BaseTest < StoreConfigurable::TestCase
@user.must_be :config_changed?
end
+ it 'can resave unsafe keys' do
+ @user.config.sortable_tables[:comments][:sort].on = 'title'
+ @user.config.sortable_tables[:comments][:sort].dir = 'asc'
+ @user.save!
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.