module Sequel::Metaprogramming

  1. lib/sequel/extensions/meta_def.rb
Parent: Sequel

Contains #meta_def method for adding methods to objects via blocks. Only recommended for backwards compatibility with existing code.

Methods

Public Instance

  1. meta_def

Public Instance methods

meta_def (name, &block)

Define a method with the given name and block body on the receiver.

ds = DB[:items]
ds.meta_def(:x){42}
ds.x # => 42
[show source]
# File lib/sequel/extensions/meta_def.rb, line 17
def meta_def(name, &block)
  (class << self; self end).send(:define_method, name, &block)
end