Sha256: 440a682cf674f6ba0cc55e85dd20cff8c124419cc035ae84b0cbe14a6ef32ab1

Contents?: true

Size: 505 Bytes

Versions: 2

Compression:

Stored size: 505 Bytes

Contents

#
# File::      DynamicClassMethods.rb
# Author::    wkm
# Copyright:: 2009
# License::   GPL
#
# Adds a #meta_def function to Object so we can programmatically define class
# methods.
#

class Object

  # defines a class method
  # based on: http://blog.jayfields.com/2007/10/ruby-defining-class-methods.html
  # and: http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
  def define_class_method name, &blk
    (class << self; self; end).instance_eval { define_method name, &blk}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sitefuel-0.0.0b lib/sitefuel/extensions/DynamicClassMethods.rb
sitefuel-0.0.0a lib/sitefuel/extensions/DynamicClassMethods.rb