my_object[1].id
"id" - , MyModel, "id =" setter (, )
my_object[1][:id] or my_object[1]["id"]
@attributes:
def read_attribute(attr_name)
attr_name = attr_name.to_s
if !(value = @attributes[attr_name]).nil?
......
end
,
def [](attr_name)
read_attribute(attr_name)
end
my_object[1][:id]
[], , , :
my_object[1][](:id)
, Ruby , , ( , php, js ..), .