Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hsume2 committed Jun 16, 2009
1 parent 091405e commit b365826
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.rdoc
Expand Up @@ -55,7 +55,7 @@ Suppose you have a lot of keys starting with +PBType+ which you want removed. Th

attr_mapped 'PBTypeName', 'PBTypeAddress', 'PBTypeCode', { :namespace => 'PBType' }

will map +PBTypeName+ to +:name+, +PBTypeAddress+ to +:address+, etc.
will map +PBTypeName+ to <tt>:name</tt>, +PBTypeAddress+ to <tt>:address</tt>, etc.

Namespaces only apply to the keys for each +attr_mapped+ call. So

Expand All @@ -64,7 +64,7 @@ Namespaces only apply to the keys for each +attr_mapped+ call. So
attr_mapped 'PBTypeAddr'
end

will map +PBTypeName+ to +:name+, but +PBTypeAddr+ to +:pb_type_addr+.
will map +PBTypeName+ to <tt>:name</tt>, but +PBTypeAddr+ to +:pb_type_addr+.

=== Mapping priority

Expand Down Expand Up @@ -92,15 +92,15 @@ will map to +:actually_this+.
=== :id

If one of the hash keys should map to the Active Record id, setting it like <tt>attr_mapped :key => :id</tt>
won't work. Active Record won't let you mass assign +:id+ anyway. Instead
won't work. Active Record won't let you mass assign <tt>:id</tt> anyway. Instead
attr_mapped 'PBTypeName', { :namespace => 'PBType', :id => 'PBKey' }
to force creation with +PBKey+'s value.

=== :serialize

You can also specify which keys to serialize after they've been mapped. Using,
attr_mapped 'PBArray', { :namespace => 'PB', :serialize => 'PBArray' }
will map +PBArray+ to +:array+ and call <tt>serialize :array</tt> in the Active Record.
will map +PBArray+ to <tt>:array</tt> and call <tt>serialize :array</tt> in the Active Record.

=== :filter

Expand Down

0 comments on commit b365826

Please sign in to comment.