Skip to content

Commit

Permalink
Autoload Espresso::Concern, removed archaic extend_module method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Semyonov committed Mar 28, 2010
1 parent b196277 commit b4e2933
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
14 changes: 3 additions & 11 deletions lib/espresso.rb
Expand Up @@ -6,6 +6,7 @@ module Espresso
autoload :View, 'espresso/view'
autoload :Controller, 'espresso/controller'
autoload :Collection, 'espresso/collection'
autoload :Concern, 'espresso/concern'

BASE_MODULES = %w(model view controller)

Expand All @@ -32,20 +33,11 @@ def self.uses(extension, extend_modules = true)
extension = extension.to_s.classify
BASE_MODULES.each do |module_name|
mod = const_get(module_name.classify)
extend_module(mod, mod.const_get(extension))
extension = mod.const_get(extension)
mod.send(:include, extension)
end
end
end

# Extend module InstanceMethods and ClassMethods with extension‘s one
# @param [Module] mod module to extend
# @param [Module] extension module, containing extensions
def self.extend_module(mod, extension)
mod.const_get(:ClassMethods).send(:include,
extension.const_get(:ClassMethods))
mod.const_get(:InstanceMethods).send(:include,
extension.const_get(:InstanceMethods))
end
end

if defined?(ActiveRecord)
Expand Down
3 changes: 1 addition & 2 deletions test/espresso_test.rb
@@ -1,6 +1,5 @@
require 'test_helper'

class EspressoTest < Test::Unit::TestCase
should_have_class_methods :configure, :uses, :extend_module,
:extensions
should_have_class_methods :configure, :uses, :extensions
end

0 comments on commit b4e2933

Please sign in to comment.