app/controllers/api.rb in bullet_train-api-1.0.5 vs app/controllers/api.rb in bullet_train-api-1.0.6
- old
+ new
@@ -4,11 +4,15 @@
# have to brute force our way around it for now. In doing so, we're implementing something not unlike the magic of the
# `t` helper in Rails views.
module Api
def self.topic
- path = caller.find { |path| path.include?("controllers/api") && !path.include?("app/controllers/api.rb") }
- path.split(/\/app\/controllers\/api\/v\d+\//).last.split("_endpoint.").first
+ path = caller.find { |path| (path.include?("controllers/api") || path.include?("app/controllers/concerns/api")) && !path.include?("app/controllers/api.rb") && !path.include?("app/controllers/api/v1/root.rb") && !path.include?("app/controllers/api/base.rb") }
+ if path.include?("controllers/api")
+ path.split(/\/app\/controllers\/api\/v\d+\//).last.split("_endpoint.").first
+ elsif path.include?("app/controllers/concerns/api")
+ path.split(/\/app\/controllers\/concerns\/api\/v\d+\//).last.split("/endpoint_base.").first
+ end
end
def self.serializer
# TODO This could be smart enough to figure out if `V1` is accurate, as well.
"Api::V1::#{Api.topic.classify}Serializer"