Class: Class

Inherits:
Object show all
Includes:
PoolParty::PluginModel
Defined in:
lib/poolparty/core/class.rb,
lib/poolparty.rb

Overview

Taken from rspec with high respect. Mainly unused, for now

Instance Method Summary collapse

Methods included from PoolParty::PluginModel

#plugin, #plugins

Instance Method Details

#subclass(base_name, &body) ⇒ Object

Creates a new subclass of self, with a name “under” our own name. Example:

x = Foo::Bar.subclass('Zap'){}
x.name # => Foo::Bar::Zap_1
x.superclass.name # => Foo::Bar


10
11
12
13
14
15
16
17
18
# File 'lib/poolparty/core/class.rb', line 10

def subclass(base_name, &body)
  klass = Class.new(self)
  class_name = "#{base_name}_#{class_count!}"
  instance_eval do
    const_set(class_name, klass)
  end
  klass.instance_eval(&body)
  klass
end