Prev | Current Page 247 | Next

Kevin Marshall, Chad Pytel, and Jon Yurek

"Pro Active Record: Databases with Ruby and Rails"

After that, using the aggregated object
will be the only way to access the overridden value. What this means is that if your table has a balance
field and you decide to create an aggregated object referenced by the name of balance, you will only be
able to get and set the balance value within the database through the implementation of the aggregated
object??”you will not be able to directly set the balance value like you do with other fields in the table, as in
Account.username = "Kevin".
CHAPTER 5 ?–  BONUS FEATURES 106
class_name
The class_name parameter specifies the name of the value object??™s class and can be any nonreserved,
standard, Ruby-like class name. This parameter is optional and, by default, assumes
the class is named the same as the aggregation??™s name. For example, both of the following
examples would reference the class Userinfo:
composed_of :userinfo, :mapping => %w(username username)
composed_of :personalstuff, :class_name => "userinfo",
:mapping => %w(username username)
mapping
The mapping parameter associates table fields with value object attributes.


Pages:
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259