markburns/to_factory

Handles modules?

aaronhumerickhouse opened this issue · 5 comments

Is this made to handle modules?

Failed to eval ./app/models/stats/soccer/soccer_defaults.rb
uninitialized constant ToFactory::Finders::Model::SoccerDefaults

module Stats
  module Soccer
    class SoccerDefaults < Stats::Defaults
     ...
    end
  end
end

No it's not but would be happy to accept a PR

As you can see it's not so actively maintained as I have tried to use the
project to save me time where it can. I just haven't personally encountered
a project that is namespaced and without factories yet

Will leave open until if/when I get a chance
On Tue, Nov 10, 2015 at 6:55 AM aaronhumerickhouse notifications@github.com
wrote:

Is this made to handle modules?

Failed to eval ./app/models/stats/soccer/soccer_defaults.rb
uninitialized constant ToFactory::Finders::Model::SoccerDefaults

module Stats
module Soccer
class SoccerDefaults < Stats::Defaults
...
end
endend


Reply to this email directly or view it on GitHub
#17.

Actually I think this should work, I haven't managed to replicate the error you are getting.
Could you give more details? Stacktrace, smallest example that can replicate it. Also what did you execute? ToFactory() ?

Just tried it out in a dummy rails app with a single level of nesting and two levels of nesting and it works.

Are you sure that the constant is being autoloaded correctly? Is the class saved in the path it tries to look?

Closing as I suspect this is a configuration issue at your end, but feel free to reopen with more info

I also had this problem

From what I analyzed the problem is in the matching_lines method of the lib/to_factory/finders/model.rb file

In my case I have a model similar to Foo::Bar and when it runs to this method of matching_lines it tries to instantiate Bar when it should instantiate Foo::Bar in the eval of line 49 of the model finder

Can you replicate in a small project or by writing a failing spec?