Sha256: 7fe334a27d137c6743f5aedbd4313971fb4a84c7c9f0e58e8dda77e1279a3688
Contents?: true
Size: 686 Bytes
Versions: 2
Compression:
Stored size: 686 Bytes
Contents
module ConcernedInheritance::ClassMethods def inherited_callbacks (self.singleton_class.ancestors + self.ancestors).select do |ancestor| ancestor.instance_variable_defined? :@inherited_callbacks end.map do |ancestor| ancestor.instance_variable_get :@inherited_callbacks end.flatten end private def inherited(subclass=nil, &block) if subclass.nil? define_inherited_callback(&block) else run_inherited_callbacks(subclass) super(subclass) end end def run_inherited_callbacks(subclass) self.inherited_callbacks.each do |callback| ConcernedInheritance::Delegator.new(self, subclass, callback) end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
concerned_inheritance-0.0.2 | lib/concerned_inheritance/class_methods.rb |
memory_model-0.0.1 | lib/concerned_inheritance/class_methods.rb |