CompanyBook / massive_record

HBase ruby client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stop casting attributes on record initialization, do it lazy in stead.

thhermansen opened this issue · comments

After this commit (bcc02d6), orm records are keeping a copy of the hash which it loaded it's attributes from. This hash will be the source of data for embeds_many proxy, but can also be used to read and cast attributes lazy from. Right now we are casting fields on initialize (

attributes[field.name] = value.nil? ? nil : field.decode(value)
), quite possibly doing more work than we need to do, since its unlikely that all attributes are accessed in a request.

So I think we don't need to do this, and instead do casting only in reader method, caching the casted result.

Looks rather old. Closing it :-)