Sha256: 10a01f4e22d1698bc6cccff25b1f7277b67459bb53fa2a288c59c4c7587ff490

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
infopark_cloud_connector-7.1.0 lib/rails_connector/cms_accessible.rb
infopark_cloud_connector-7.0.2 lib/rails_connector/cms_accessible.rb