lib/concerned/module_ext.rb in concerned-0.1.3 vs lib/concerned/module_ext.rb in concerned-0.1.4
- old
+ new
@@ -15,13 +15,16 @@
end
end
def include_concerns(*concerns)
options = concerns.extract_options!
+ scope_name = options[:for] ? options[:for] : name
concerns.flatten.each do |concern|
next if concern.blank?
- require_concern name, concern
- concern_ns = [name, concern.to_s.camelize].join('::')
+ require_concern scope_name, concern
+
+ concern_ns ||= [scope_name.to_s.camelize, concern.to_s.camelize].join('::')
+
self.send :include, concern_ns.constantize
if Concerned.extend_enabled?
begin
self.extend [concern_ns, 'ClassMethods'].join('::').constantize