cypriss/mutations — pull request #8 by edwinv (2013-03-01 09:09:26+00:00)
Title: Initialize model classes upon filtering, not on class load

We are using the mutations gem in a project and experienced issues with mocking out model classes. Because the `ModelFilter` is initialized upon class load, it is not possible to first mock a model. In our unit tests, we completely mock out our ActiveRecord model:

```ruby
class MyMutation
required do
model :my_model
end
end

class MyModel < ActiveRecord::Base
end

describe MyMutation do

before do
mock_model("MyModel")
end

it "..." do
# Some tests
end

end
```

This code would raise a `constant ActiveRecord not found` exception because mutations tries to constantize `my_model` when loading the `MyMutation` class. I think it is better to look for the model class when the actual filtering is happing, this allows for easier mocking of these classes.