Sha256: 74a78d990ef21a1c5237adbeb1c76d2f532cf121608e69604e455d38f7a10bed

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

module Qbrick
  class ImageSizeDelegator
    def method_missing(method, *args, &block)
      Qbrick::ImageSize.send(method, *args, &block)
    rescue NoMethodError
      super
    end
  end

  class Engine < ::Rails::Engine
    isolate_namespace Qbrick

    config.i18n.fallbacks = [:de]
    config.i18n.load_path += Dir[Qbrick::Engine.root.join('config/locales/**/*.{yml}').to_s]

    # defaults to nil
    config.sublime_video_token = nil

    # delegate image size config to ImageSize class
    config.image_sizes = ImageSizeDelegator.new

    initializer 'qbrick.initialize_haml_dependency_tracker' do
      require 'action_view/dependency_tracker'
      ActionView::DependencyTracker.register_tracker :haml, ActionView::DependencyTracker::ERBTracker
    end

    def app_config
      Rails.application.config
    end

    def hosts
      [Socket.gethostname].tap do |result|
        result.concat [app_config.hosts].flatten if app_config.respond_to? :hosts
        result.concat [app_config.host].flatten if app_config.respond_to? :host
      end
    end

    def host
      return hosts.first unless app_config.respond_to? :host

      app_config.host
    end

    def scheme
      return 'http' unless app_config.respond_to? :scheme

      app_config.scheme
    end

    def port
      return 80 unless app_config.respond_to? :port

      app_config.port
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qbrick-2.6.9 lib/qbrick/engine.rb
qbrick-2.6.8 lib/qbrick/engine.rb
qbrick-2.6.7 lib/qbrick/engine.rb