Commit 1e9a75ee by Cuong Tran

Merge pull request #38 from mcommons/master

Allow for non standard model capitalization (mcommons/master)
parents ddfba1f7 248e6650
......@@ -239,7 +239,11 @@ module AnnotateModels
begin
parts.inject(Object) {|klass, part| klass.const_get(part) }
rescue LoadError, NameError
Object.const_get(parts.last)
begin
Object.const_get(parts.last)
rescue LoadError, NameError
Object.const_get(Module.constants.detect{|c|parts.last.downcase == c.downcase})
end
end
end
......
......@@ -69,6 +69,11 @@ EOS
acts_as_awesome :yah
end
EOS
create('foo_with_capitals.rb', <<-EOS)
class FooWithCAPITALS < ActiveRecord::Base
acts_as_awesome :yah
end
EOS
end
it "should work" do
klass = AnnotateModels.get_model_class("foo.rb")
......@@ -78,6 +83,10 @@ EOS
klass = AnnotateModels.get_model_class("foo_with_macro.rb")
klass.name.should == "FooWithMacro"
end
it "should find models with non standard capitalization" do
klass = AnnotateModels.get_model_class("foo_with_capitals.rb")
klass.name.should == "FooWithCAPITALS"
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment