Skip to content

joshnabbott/better_delegation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

better_delegation

Better method delegation for ActiveRecord. Specifically when it comes to handling ‘nil’ objects.

While Rails does support method delegation to a nil object, it will always return ‘nil’ if the object delegated to is nil.

This gem will return whatever the object delegated to would return. It’s especially useful for example when you have a method that would typically return ‘false’ (because that’s what the database column default is set to). For example an ‘is_active` method might return false by default. When the delegating object calls `is_active` on a nil object, the nil object would return ’false’, not nil.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but

    bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright © 2009 Josh N. Abbott. See LICENSE for details.

About

Better method delegation for ActiveRecord classes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages