module RailsConnector # @api public module CmsAccessible protected # Filter method to load a CMS object. # # To require the loading for all actions, use this in your controllers: # before_filter :load_object def load_object CmsEnv.new(request.env).load loaded_obj = request.env[CmsEnv::OBJ_ENV_KEY] raise loaded_obj if loaded_obj.is_a?(StandardError) @obj = loaded_obj end # Deliver a binary @obj by redirecting to it's `body_data_url`. # Will respond with 404 if the @obj has no blob. # @api public def deliver_file if @obj.body_data_url redirect_to enforce_protocol_from_request(@obj.body_data_url) else render text: "Empty Blob", status: 404 end end end end