Add auto-stripping of question mark for attributes

This commit is contained in:
Andrey Krivko
2014-09-26 15:42:41 +07:00
parent 40d53aaa16
commit bded293529
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