public
Description: a ruby on rails plugin to create and display a social feed
Homepage: http://upstream-berlin.com/blog/open-source/#social_feed
Clone URL: git://github.com/langalex/social_feed.git
Search Repo:
social_feed / lib / object_extensions.rb
100644 26 lines (22 sloc) 0.287 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Object
  def try(method, *params)
    send method, *params if respond_to? method
  end
end
 
class Object
  def if_nil?
    self
  end
  
  def if_not_nil?
    yield self
  end
end
 
class NilClass
  def if_nil?
    yield self
    self
  end
  
  def if_not_nil?
    self
  end
end