Class: Nyanko::Unit::Extender

Inherits:
Object
  • Object
show all
Defined in:
lib/nyanko/unit/extender.rb,
lib/nyanko/unit/extender/extension.rb,
lib/nyanko/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/nyanko/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/nyanko/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