Class: Chanko::Unit::Extender

Inherits:
Object
  • Object
show all
Defined in:
lib/chanko/unit/extender.rb,
lib/chanko/unit/extender/extension.rb,
lib/chanko/unit/extender/active_record_class_methods.rb

Defined Under Namespace

Modules: ActiveRecordClassMethods Classes: Extension

Instance Method Summary collapse

Constructor Details

#initialize(prefix = nil) ⇒ Extender

Returns a new instance of Extender.



7
8
9
# File 'lib/chanko/unit/extender.rb', line 7

def initialize(prefix = nil)
  @prefix = prefix
end

Instance Method Details

#expand(mod, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/chanko/unit/extender.rb', line 11

def expand(mod, &block)
  mod       = mod.to_s.camelize.constantize unless mod.is_a?(Module)
  extension = Extension.new(mod, @prefix, &block)
  mod.class_eval do
    include extension.instance_methods_module
    extend extension.class_methods_module
  end
end