The comment at https://github.com/cypriss/mutations/blob/master/lib/mutations/model_filter.rb#L5
# default is the attribute name.to_s.camelize.constantize.
indicates that the class of a model (if not given) is generated using the attribute name. But there is no way for the filter to know the name of the attribute, because it's never passed to the initializer:
# https://github.com/cypriss/mutations/blob/master/lib/mutations/hash_filter.rb#L8
@current_inputs[name.to_sym] = type_class.new(options, &block)
the name is never passed to the constructor, with two nasty consequences:
- There is no way to set the model class from the name of the attribute.
- The options in the filter initializer are always empty, so the class constraint always resolves to
Object, making it totally useless.
update
the ModelFilter is treated very differently than the rest of filters, so this actually applies only to custom additional filters, not to the model filter itself.
The comment at https://github.com/cypriss/mutations/blob/master/lib/mutations/model_filter.rb#L5
# default is the attribute name.to_s.camelize.constantize.indicates that the class of a model (if not given) is generated using the attribute name. But there is no way for the filter to know the name of the attribute, because it's never passed to the initializer:
the name is never passed to the constructor, with two nasty consequences:
Object, making it totally useless.update
the
ModelFilteris treated very differently than the rest of filters, so this actually applies only to custom additional filters, not to the model filter itself.