Sha256: 561de1df474e5110c0dbf2dfe95b14d7eccec5815157aefefb85b699369d9095

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

class Module 

	alias :original_append_features :append_features

	# after include module, convert methods in ClassMethods to class methods. a very clean design.
	# @see ruby-core Module#append_features
	#
	# @example
	#   module Guten
	#   	module ClassMethods
	#   		def foo; end      # this is class method.
	#   	end
	#
	#    def bar; end # this is instance method. 
	#	  end
	#  
	#   class Tag
	#   	include Guten  # will auto Tag.extend(Guten::Classmethods)
	#	  end
	#
	def append_features base
		original_append_features base
		base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
	end

end #class Module

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tagen-0.2.4 lib/tagen/core/module.rb
tagen-0.2.3 lib/tagen/core/module.rb