Sha256: 08cfdd4ea429eff69b63322e4a03fc7b143607765ae423900c96e592809dcc5d

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'rails_connector/core_extensions'

# @api public
module ::RailsConnector
  PLATFORM_CLOUD = :cloud.freeze
  PLATFORM_FIONA = :fiona.freeze

  def self.load_platform_gem_if_present(name)
    if Gem.loaded_specs["infopark_#{name}_connector"]
      gem_name = "infopark_#{name}_connector"

      # ensure the other connector is present in exactly the same version
      gem gem_name, Gem.loaded_specs["infopark_rails_connector"].version

      require gem_name

      @platform = name
    end
  end

  # return either <tt>:fiona</tt> or <tt>:cloud</tt> depending on the app's configuration.
  # @return [Symbol]
  def self.platform
    @platform
  end

  def self.platform_cloud?
    @platform == PLATFORM_CLOUD
  end

  def self.platform_fiona?
    @platform == PLATFORM_FIONA
  end
end

RailsConnector::load_platform_gem_if_present(RailsConnector::PLATFORM_CLOUD)
RailsConnector::load_platform_gem_if_present(RailsConnector::PLATFORM_FIONA)

unless RailsConnector::platform
  raise "The infopark_rails_connector gem requires "\
    "either the infopark_cloud_connector gem (for use with Infopark Cloud Express) or "\
    "the infopark_fiona_connector gem (for use with Infopark CMS Fiona). "\
    "Add either gem to your Gemfile."
end

require "rails_connector/engine" if defined?(Rails)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
infopark_rails_connector-6.9.4 lib/infopark_rails_connector.rb
infopark_rails_connector-6.9.3.1.36404185 lib/infopark_rails_connector.rb
infopark_rails_connector-6.9.2.1.125136549 lib/infopark_rails_connector.rb
infopark_rails_connector-6.9.1.3.22208381 lib/infopark_rails_connector.rb
infopark_rails_connector-6.9.0.3.197272233 lib/infopark_rails_connector.rb
infopark_rails_connector-6.8.3.174.51542603 lib/infopark_rails_connector.rb