Merge pull request #662 from jastkand/remove-question-sign

Add auto-stripping of question mark for attributes
This commit is contained in:
Steve Klabnik
2014-09-26 10:35:43 -04:00
3 changed files with 32 additions and 4 deletions

View File

@@ -1,11 +1,13 @@
class Model
def initialize(hash={})
def initialize(hash = {})
@attributes = hash
end
def read_attribute_for_serialization(name)
if name == :id || name == 'id'
object_id
elsif respond_to?(name)
send name
else
@attributes[name]
end