def method_missing(method_id, *arguments, &block)
match, attribute_names, translated_attributes, untranslated_attributes = supported_on_missing?(method_id)
return super unless match
scope = scoped
translated_attributes.each do |attr|
scope = scope.with_translated_attribute(attr, arguments[attribute_names.index(attr)])
end
untranslated_attributes.each do |unt|
index = attribute_names.index(unt)
raise StandarError unless index
scope = scope.send("scoped_by_#{unt}""scoped_by_#{unt}", arguments[index])
end
if defined?(::ActiveRecord::DynamicFinderMatch) && match.is_a?(::ActiveRecord::DynamicFinderMatch)
if match.instantiator? and scope.blank?
return scope.find_or_instantiator_by_attributes match, attribute_names, *arguments, &block
end
match_finder_method = match.finder.to_s
match_finder_method << "!" if match.bang? && ::ActiveRecord::VERSION::STRING >= "3.1.0"
return scope.send(match_finder_method).tap do |found|
found.is_a?(Array) ? found.map { |f| f.translations.reload } : found.translations.reload unless found.nil?
end
end
return scope
end