-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
array :things; model; end no longer infers class name Thing #224
Labels
Comments
Should it work this way? Should the name given to the array assume it's a model type by default? |
I think it should work this way. The name of the filter inside an array doesn't have any meaning. It could be called class A < ActiveInteraction::Base
array :ids do
integer
end
end
A.filters[:ids].filters
# Current:
# => {:ids=>#<ActiveInteraction::IntegerFilter:0x... @name=:ids, ...>}
# Proposed:
# => {:id=>#<ActiveInteraction::IntegerFilter:0x... @name=:id, ...>}
class B < ActiveInteraction::Base
array :objects do
model
end
end
B.filters[:objects].filters
# Current:
# => {:objects=>#<ActiveInteraction::ModelFilter:0x... @name=:objects, ...>}
# Proposed:
# => {:object=>#<ActiveInteraction::ModelFilter:0x... @name=:object, ...>} And for what it's worth, it's a pretty simple change. diff --git a/lib/active_interaction/filters/array_filter.rb b/lib/active_interaction/filters/array_filter.rb
index 98ed4e1..2b39f3f 100644
--- a/lib/active_interaction/filters/array_filter.rb
+++ b/lib/active_interaction/filters/array_filter.rb
@@ -41,11 +41,11 @@ module ActiveInteraction
def method_missing(*, &block)
super do |klass, names, options|
- filter = klass.new(name, options, &block)
+ filter = klass.new(name.to_s.singularize.to_sym, options, &block)
validate(filter, names)
- filters[name] = filter
+ filters[filter.name] = filter
end
end
|
ok |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: