Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/vidibus/core_extensions/object.rb
Instance Method Summary collapse
-
#to_query(key) ⇒ Object
Turns object into a key-value pair.
-
#try!(method) ⇒ Object
Tries to use a method on object.
Instance Method Details
#to_query(key) ⇒ Object
Turns object into a key-value pair. Stolen from active_support/core_ext
19 20 21 22 |
# File 'lib/vidibus/core_extensions/object.rb', line 19 def to_query(key) require "cgi" unless defined?(CGI) && defined?(CGI::escape) "#{CGI.escape(key.to_s)}=#{CGI.escape(to_s)}" end |
#try!(method) ⇒ Object
Tries to use a method on object.
Example:
something.try!(:else) # => nil
8 9 10 11 12 13 14 15 |
# File 'lib/vidibus/core_extensions/object.rb', line 8 def try!(method) begin send(method) rescue NoMethodError rescue => e raise e end end |