Right now you can configure virtus global attribute options and coercers using Virtus module. The idea is to replace that with a module builder so that you can create as many virtus modules to be included in your classes as you need where each of those modules would have its own configuration.
For instance it could look like that:
# create customized virtus module
MyCustomVirtusModule = Virtus.configure { |config|
config.coercion = true
# some extra conf should be possible too
config.string.boolean_map = { 'yup' => true, 'nope' => false }
}
class Book
include MyCustomVirtusModule
attribute :published, Boolean
end
This way we won't be polluting global Virtus constant and provide ability to use Virtus in different ways depending on the context. For instance in form-like objects you want to have coercions turned on but in pure domain objects you may want to have coercions turned off. Or you could use strict-mode for coercion where unknown coercion raises an exception in one place and have it turned off in other etc.
Right now you can configure virtus global attribute options and coercers using Virtus module. The idea is to replace that with a module builder so that you can create as many virtus modules to be included in your classes as you need where each of those modules would have its own configuration.
For instance it could look like that:
This way we won't be polluting global Virtus constant and provide ability to use Virtus in different ways depending on the context. For instance in form-like objects you want to have coercions turned on but in pure domain objects you may want to have coercions turned off. Or you could use strict-mode for coercion where unknown coercion raises an exception in one place and have it turned off in other etc.