Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adds before_inner_class_inheritance hook

  • Loading branch information...
commit 220527a0e7d8354a49be3bc8fa8a0ce5a5438586 1 parent 99b8d18
Daniel Neighman authored
4 bin/pancake
@@ -24,6 +24,10 @@ desc "list [SEARCH]", "List the available pancake tasks (--substring means .*SEA
24 24
25 25 def method_missing(meth, *args, &blk)
26 26 klass, task = Thor::Util.find_class_and_task_by_namespace(meth.to_s)
  27 + unless klass
  28 + puts "Could not find a generator for #{meth.to_s}"
  29 + exit(1)
  30 + end
27 31 args.unshift(task) if task
28 32 klass.start(args, :shell => self.shell)
29 33 end
2  lib/pancake/core_ext/object.rb
@@ -19,4 +19,4 @@ def instance_exec(*args, &block)
19 19 ret
20 20 end
21 21 end
22   -end
  22 +end
17 lib/pancake/hooks/inheritable_inner_classes.rb
@@ -3,8 +3,9 @@ module Hooks
3 3 module InheritableInnerClasses
4 4 def self.extended(base)
5 5 base.class_eval do
6   - extlib_inheritable_reader :_inhertiable_inner_classes
7   - @_inhertiable_inner_classes = []
  6 + extlib_inheritable_reader :_inhertiable_inner_classes, :_before_inner_class_inheritance
  7 + @_inhertiable_inner_classes = []
  8 + @_before_inner_class_inheritance = []
8 9 end
9 10 end # extended
10 11
@@ -40,6 +41,16 @@ def inheritable_inner_classes(*classes)
40 41 _inhertiable_inner_classes
41 42 end
42 43
  44 + # Runs any hooks before the inheritance of any inner classes
  45 + #
  46 + # @api public
  47 + # @since 0.3.0
  48 + # @author Daniel Neighman
  49 + def before_inner_class_inheritance(&blk)
  50 + _before_inner_class_inheritance << blk if blk
  51 + _before_inner_class_inheritance
  52 + end
  53 +
43 54 # The inherited hook that sets up inherited inner classes. Remember if you overwrite this method, you should
44 55 # call super!
45 56 #
@@ -49,11 +60,13 @@ def inheritable_inner_classes(*classes)
49 60 def inherited(base)
50 61 super
51 62 class_defs = inheritable_inner_classes.map do |klass|
  63 + _before_inner_class_inheritance.each{|blk| blk.call(base.superclass) }
52 64 "class #{klass} < superclass::#{klass}; end\n"
53 65 end
54 66 base.class_eval(class_defs.join)
55 67 end
56 68
  69 +
57 70 end # InheritableInnerClasses
58 71 end # Hooks
59 72 end # Pancake
1  lib/pancake/stack/stack.rb
@@ -23,6 +23,7 @@ class Stack
23 23
24 24 #Iterates the list of roots in the stack, and initializes the app found their
25 25 def self.initialize_stack(opts = {})
  26 + return if @initialized
26 27 raise "Stack root not set" if roots.empty?
27 28 master = opts.delete(:master)
28 29 set_as_master! if master

0 comments on commit 220527a

Please sign in to comment.
Something went wrong with that request. Please try again.