Sha256: 93303584909a40b9f77958446e548aec0acbc4891c16f9c2fd16d50625ab6df5

Contents?: true

Size: 666 Bytes

Versions: 4

Compression:

Stored size: 666 Bytes

Contents

# why the lucky stiff's helper for making metaclasses
# easily available and usable
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

4 entries across 4 versions & 1 rubygems

Version Path
fossil-0.5.3 lib/sequel/metaprogramming.rb
fossil-0.5.2 lib/sequel/metaprogramming.rb
fossil-0.5.1 lib/sequel/metaprogramming.rb
fossil-0.5.0 lib/sequel/metaprogramming.rb