From 204c0c65f47e4730eff28aaf43009521d52b7514 Mon Sep 17 00:00:00 2001 From: Philip Arndt Date: Tue, 22 May 2012 18:45:46 +1200 Subject: [PATCH] Switched to ActiveSupport::Inflector#underscore as ActiveModel::Name#underscore seems to have gone --- core/lib/refinery/core.rb | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/core/lib/refinery/core.rb b/core/lib/refinery/core.rb index 071adbebbf..090e4b6782 100644 --- a/core/lib/refinery/core.rb +++ b/core/lib/refinery/core.rb @@ -102,7 +102,10 @@ def deprecate(what, options = {}) # See if we can trace where this happened if options[:caller] - whos_calling = options[:caller].detect{|c| c =~ %r{#{Rails.root.to_s}}}.inspect.to_s.split(':in').first + whos_calling = options[:caller].detect{|c| + %r{#{Rails.root.to_s}} === c + }.inspect.to_s.split(':in').first + warning << "\nCalled from: #{whos_calling}\n" end @@ -155,13 +158,16 @@ def route_for_model(klass, options = {}) options = {:plural => false, :admin => true}.merge options klass = klass.constantize if klass.respond_to?(:constantize) - active_name = ActiveModel::Name.new klass, (Refinery if klass.parents.include?(Refinery)) + active_name = ::ActiveModel::Name.new( + klass, (Refinery if klass.parents.include?(Refinery)) + ) if options[:admin] # Most of the time this gets rid of 'refinery' - parts = active_name.underscore.split('/').reject{|name| - active_name.singular_route_key.exclude?(name) - } + parts = ActiveSupport::Inflector.underscore(active_name) + .split('/').reject{|name| + active_name.singular_route_key.exclude?(name) + } # Get the singular resource_name from the url parts resource_name = parts.pop @@ -176,7 +182,9 @@ def route_for_model(klass, options = {}) end def include_once(base, extension_module) - base.send :include, extension_module unless included_extension_module?(base, extension_module) + unless included_extension_module?(base, extension_module) + base.send :include, extension_module + end end private @@ -184,7 +192,8 @@ def include_once(base, extension_module) def included_extension_module?(base, extension_module) if base.kind_of?(Class) direct_superclass = base.superclass - base.ancestors.take_while {|ancestor| ancestor != direct_superclass}.include?(extension_module) + base.ancestors.take_while {|ancestor| ancestor != direct_superclass} + .include? extension_module else base < extension_module # can't do better than that for modules end