Class: Sequel::BasicObject

Inherits:
BasicObject
Defined in:
lib/sequel/sql.rb,
lib/sequel/sql.rb

Overview

If on 1.9, create a Sequel::BasicObject class that is just like the default BasicObject class, except that missing constants are resolved in Object. This allows the virtual row support to work with classes without prefixing them with ::, such as:

DB[:bonds].filter{maturity_date > Time.now}

Constant Summary collapse

KEEP_METHODS =

The instance methods to not remove from the class when removing other methods.

%w"__id__ __send__ __metaclass__ instance_eval instance_exec == equal? initialize method_missing"

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

Lookup missing constants in ::Object



30
31
32
# File 'lib/sequel/sql.rb', line 30

def self.const_missing(name)
  ::Object.const_get(name)
end

.remove_methods!Object

No-op method on ruby 1.9, which has a real BasicObject class.



15
16
17
# File 'lib/sequel/sql.rb', line 15

def self.remove_methods!
  ((private_instance_methods + instance_methods) - KEEP_METHODS).each{|m| undef_method(m)}
end