Permalink
Browse files

add nice inspect for generated BigBand subclasses

  • Loading branch information...
1 parent 8bd519a commit d0aa07000354d2b595aa6a9681d81a700ebdc93e @rkh committed May 1, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/sinatra/big_band.rb
View
6 lib/sinatra/big_band.rb
@@ -31,9 +31,11 @@ def self.apply_options(klass)
enable :sessions
end
- def self.subclass_for(list)
+ def self.subclass_for(list, inspection = nil)
@subclasses ||= {}
@subclasses[list] ||= Class.new(self) do
+ @inspection = inspection
+ define_singleton_method(:inspect) { @inspection || super() }
define_singleton_method(:inherited) do |klass|
super klass
list.each { |block| block.call klass }
@@ -51,7 +53,7 @@ def self.generate_subclass(options = {})
extension = parent.const_get name
chosen << proc { |klass| klass.register extension }
end
- subclass_for list
+ subclass_for list, "#{self}(#{options.inspect[1..-2]})"
end
end

0 comments on commit d0aa070

Please sign in to comment.