Skip to content

ggoodale/attr_private

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

class MyModel < ActiveRecord::Base
  attr_private :my_field, :some_other_field
end

Currently, attr_private doesn’t prevent reading via the attributes hash.

  • reQall for letting me hack in Ruby

  • Evan Light for pushing me to make this a gem (my first!)

About

attr_private provides a way of making fields on an ActiveRecord model inaccessible to users of that model.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages