Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/activesupport/lib/active_support/basic_object.rb

Revision 9093, 0.8 kB (checked in by pratik, 3 months ago)

Improve documentation.

Line 
1 # A base class with no predefined methods that tries to behave like Builder's
2 # BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
3 # Builder::BlankSlate class.
4 #
5 # Ruby 1.9 introduces BasicObject which differs slightly from Builder's
6 # BlankSlate that has been used so far. ActiveSupport::BasicObject provides a
7 # barebones base class that emulates Builder::BlankSlate while still relying on
8 # Ruby 1.9's BasicObject in Ruby 1.9.
9 module ActiveSupport
10   if RUBY_VERSION >= '1.9'
11     class BasicObject < ::BasicObject
12       undef_method :==
13       undef_method :equal?
14
15       # Let ActiveSupport::BasicObject at least raise exceptions.
16       def raise(*args)
17         ::Object.send(:raise, *args)
18       end
19     end
20   else
21     require 'blankslate'
22     BasicObject = BlankSlate
23   end
24 end
Note: See TracBrowser for help on using the browser.