Skip to content
This repository has been archived by the owner on Mar 22, 2021. It is now read-only.

Commit

Permalink
Update keywords section
Browse files Browse the repository at this point in the history
  • Loading branch information
paulelliott committed Jun 6, 2013
1 parent 96132da commit ae13ce4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions views/_content.markdown
Expand Up @@ -89,14 +89,23 @@ one are available via a block parameter.
email { |attrs| "#{attrs[:name].parameterize}@example.com" }
end

#### Reserved Words ####
#### Keywords ####
** Using keywords for field names is not a best practice! **

You can reference fields whose names are reserved words with the block variable.
You can reference fields whose names are reserved keywords (alias, class, def, if, while, ...) with the block variable.

class Person
attr_accessor :alias, :codename
alias aka codename
end

Fabricator(:person) do |f|
f.alias 'James Bond'
codename '007'
end

Fabricate(:person).aka #=> '007'

#### Associations

You can associate another fabricator by just writing the attribute name.
Expand Down

0 comments on commit ae13ce4

Please sign in to comment.