0

I have a few method I would like to add to that but am not 100% sure what's going on there.

Is it including some kind of factory method?

Dr. Chocolate
  • 2,043
  • 4
  • 25
  • 45
  • I would start reading [here](https://github.com/solnic/virtus/blob/master/lib/virtus.rb#L151). Can you give an example of want you want to change or add to `Virtus`? – spickermann Mar 19 '16 at 15:09
  • I just want to add some methods to fetch attribute collections by type. For example: `MyModel.get_string_list` would return the name of all of the attributes that have string defined as their type. It didn't seem correct to encapsulate this on the models and would be more DRY to monkeypatch it on Virtus itself. I think? – Dr. Chocolate Mar 19 '16 at 15:24
  • I can view the source by running `show-source Virtus.model` in Pry. As expected, it returns a module (of type `ModelBuilder` / `Builder`). I don't really understand what this does either but it does seem like a factory method. Probably not the right place to patch to add your method. Find where similar methods are defined in the Virtus source code. This is how you'll know where to patch. Alternatively, you could clone the gem, edit the source directly, and specify it's local path in your Gemfile. This way you can make a pull request for your update to the gem. – max pleaner Mar 19 '16 at 17:02

0 Answers0