Module: Obsidian::Extensions::Try

Defined in:
lib/obsidian/extensions/try.rb

Instance Method Summary collapse

Instance Method Details

#try(method) ⇒ Object

Instead of

@person ? @person.name : nil

Use try:

@person.try(:name)


8
9
10
# File 'lib/obsidian/extensions/try.rb', line 8

def try(method)
  send method if respond_to? method
end