diff vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb @ 117:af80e5618e9b redmine-1.1

* Update to Redmine 1.1-stable branch (Redmine SVN rev 4707)
author Chris Cannam
date Thu, 13 Jan 2011 12:53:21 +0000
parents 94944d00e43c
children 051f544170fe
line wrap: on
line diff
--- a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb	Fri Nov 19 14:05:24 2010 +0000
+++ b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb	Thu Jan 13 12:53:21 2011 +0000
@@ -50,6 +50,21 @@
                                  :order => 'position')
         end
         
+        # Sets the values of the object's custom fields
+        # values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}]
+        def custom_fields=(values)
+          values_to_hash = values.inject({}) do |hash, v|
+            v = v.stringify_keys
+            if v['id'] && v.has_key?('value')
+              hash[v['id']] = v['value']
+            end
+            hash
+          end
+          self.custom_field_values = values_to_hash
+        end
+
+        # Sets the values of the object's custom fields
+        # values is a hash like {'1' => 'foo', 2 => 'bar'}
         def custom_field_values=(values)
           @custom_field_values_changed = true
           values = values.stringify_keys