ggoodale / attr_private
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
commit 764f476c10abaaa25c2ea4b01c9503e1099f1e7f
tree 02cf4b76cedac38c6b1b9ca4a7c6ddb8bbc1c245
parent e785dd634c332cbb5307755a1b667038b811fbd7
tree 02cf4b76cedac38c6b1b9ca4a7c6ddb8bbc1c245
parent e785dd634c332cbb5307755a1b667038b811fbd7
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
CHANGES | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
attr_private.gemspec | ||
| |
lib/ | ||
| |
spec/ |
README.rdoc
attr_private
attr_private is a way to hide fields on an ActiveRecord model such that they are inaccessible to external callers. fields declared private are protected from most access methods provided by AR. Attempts to access a private field will raise a NoMethodError as though the field did not exist.
Using attr_private
app/models/my_model.rb
class MyModel < ActiveRecord::Base
attr_private :my_field, :some_other_field
end
Limitations
Currently, attr_private doesn’t prevent reading via the attributes hash.
Special Thanks To
- reQall for letting me hack in Ruby
- Evan Light for pushing me to make this a gem (my first!)

