You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building some "Form Objects" serialized as json for use with client side schema libraries. As such, I do not need the entire CSV gem, so I've added it via gem 'client_side_validations', require: false
# Only include required modules from CSV for building JSON schemarequire'client_side_validations/config'require'client_side_validations/active_model'classCSVModelProxyincludeClientSideValidations::ActiveModel::Validationsdefinitialize(original_model)@original_model=original_modelend# Pass along all methods called by CSV (or anyone) to its original instancedefmethod_missing(method_name, *args)@original_model.send(method_name, *args) || superendend
Hello! As mentioned in my comment here: #795 (comment)
I'm building some "Form Objects" serialized as json for use with client side schema libraries. As such, I do not need the entire CSV gem, so I've added it via
gem 'client_side_validations', require: false
However, I noticed here that CSV is included in all instances of ActiveRecord, which I don't really need for my purposes. So as a workaround, I've created a
CSVModelProxy
class that includes them manually:This seems to work well (performance implications still TBD). But then, I noticed CSV also includes all its modules on all instances of ActiveModel::Validations and ActiveModel::Validator. Again this is overkill for my purposes, and I'd rather not introduce any complications into our
ActiveModel::Model
instances when I'm really just using CSV as a sort of serializer tool.So it would be nice to have the option to only import some kind of wrapper class, e.g.
Would you be interested in a PR to achieve this?
The text was updated successfully, but these errors were encountered: