Project

easy_nils

0.0
No commit activity in last 3 years
No release in over 3 years
Simpler nil handling.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

EasyNils¶ ↑

Why write this

user && user.account && user.account.authorized?

when what you want is this

user.account.authorized?

EasyNils lets you abridge compound conditional expressions returning nil if any of the method calls return nil.

Resources¶ ↑

Install

  • sudo gem install easy_nils

Use

  • require ‘easy_nils’

Rails

  • gem.config ‘easy_nils’

Usage¶ ↑

If you need to explicitly test for a nil value, then do so

if user.account.authorized?
  ... do something for an authorized account
elsif user.nil? || user.account.nil?
  ... do something here for the nil case
else
  ... do someting for an unauthorized account
end

Dependencies¶ ↑

  • meta_programming