emmanuel/virtus — comment on commit 1548148026f0a4d3728668e7b6734350f01b487b
File: lib/virtus/class_methods.rb line 16
By dkubb:

Oh wait, I see where attribute_module is used now. It makes sense that you would want a method to initialize the module and a separate one to access it.

You could do something like this:

```ruby
def self.extended(descendant)
super
descendant.extend(DescendantsTracker)
descendant.virtus_include_attribute_module

end

private

def virtus_include_attribute_module
include @virtus_attribute_module = AttributeAccessor.new(name)
end

# this could even probably be a *private* attr_reader method
def virtus_attribute_module
@virtus_attribute_module
end
```

I realize there is a tension here between keeping the number of virtus_* methods down, and having code that is more explicit and easier to understand. In this specific case I would rather opt to avoid relying on a method's _implementation_ as a side-effect, and make it explicit what's happening. Maybe you can think of a better way than what I've written above, and I would love to see what your thoughts are.