Sha256: 630178bda6966be1c78deb54fe967f8ce4ac9513efa8e9fc6548906cdcfcb1fb

Contents?: true

Size: 815 Bytes

Versions: 46

Compression:

Stored size: 815 Bytes

Contents

module Sequel
  module Metaprogramming
    # Defines an class method within a class
    def inst_def name, &blk
      instance_eval { define_method name, &blk }
    end
  end
end

# why the lucky stiff's helper for making metaclasses
class Object
  # The hidden singleton lurks behind everyone
  def metaclass; class << self; self; end; end
  def meta_eval &blk; metaclass.class_eval &blk; end

  # Adds methods to a metaclass
  def meta_def name, &blk
    meta_eval { define_method name, &blk }
  end

  def inst_def name, &blk
    define_method name, &blk
  end

  # Defines an instance method within a class
  def class_def name, &blk
    class_eval { define_method name, &blk }
  end

  # Defines an class method within a class
  def inst_def name, &blk
    instance_eval { define_method name, &blk }
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
fossil-0.5.10 lib/sequel/metaprogramming.rb
fossil-0.5.9 lib/sequel/metaprogramming.rb
fossil-0.5.8 lib/sequel/metaprogramming.rb
fossil-0.5.7 lib/sequel/metaprogramming.rb
fossil-0.5.6 lib/sequel/metaprogramming.rb
fossil-0.5.5 lib/sequel/metaprogramming.rb