Sha256: b4bbdd6918478701c90b139bb3ac611f8776b8915adf258128b99a9b9d611588

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

module Seabright
	
	def RedisObject.constant_lookups
		@constant_lookups ||= {}
	end
	
	module InheritanceTracking
		
		module ClassMethods
			
			def inherited(child_class)
				RedisObject.constant_lookups[child_class.name.to_s.split("::").last.to_sym] ||= child_class
				child_classes_set.add(child_class)
			end

			def child_classes_set
				@child_classes_set ||= Set.new
			end

			def child_classes
				child_classes_set.to_a
			end
		end

		def self.included(base)
			base.extend(ClassMethods)
		end
		
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_object-1.5.3 lib/redis_object/inheritance_tracking.rb