Permalink
Browse files

read_attribute_before_type_cast should accept symbol

  • Loading branch information...
1 parent e4ec944 commit 3e0c06d8ab1879539964c7b6c805eff870a80cbb Neeraj Singh committed May 11, 2013
@@ -1,3 +1,7 @@
+* Method read_attribute_before_type_cast should accept input as symbol.
+
+ *Neeraj Singh*
+
* Confirm a record has not already been destroyed before decrementing counter cache.
*Ben Tucker*
@@ -41,8 +41,9 @@ module BeforeTypeCast
# task.read_attribute_before_type_cast('id') # => '1'
# task.read_attribute('completed_on') # => Sun, 21 Oct 2012
# task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
+ # task.read_attribute_before_type_cast(:completed_on) # => "2012-10-21"
def read_attribute_before_type_cast(attr_name)
- @attributes[attr_name]
+ @attributes[attr_name.to_s]
end
# Returns a hash of attributes before typecasting and deserialization.
@@ -130,6 +130,7 @@ def test_id_before_type_cast_with_custom_primary_key
assert_equal '10', keyboard.id_before_type_cast
assert_equal nil, keyboard.read_attribute_before_type_cast('id')
assert_equal '10', keyboard.read_attribute_before_type_cast('key_number')
+ assert_equal '10', keyboard.read_attribute_before_type_cast(:key_number)
end
# Syck calls respond_to? before actually calling initialize

0 comments on commit 3e0c06d

Please sign in to comment.