Sha256: 060a9fd668702ddf451bfbf57e4e9eca9f7c6ae5955110671c3060ebc2be08d8

Contents?: true

Size: 524 Bytes

Versions: 62

Compression:

Stored size: 524 Bytes

Contents

module Workarea
  module MountPoint
    mattr_accessor :cache

    def self.find(klass)
      self.cache ||= {}
      return cache[klass] if cache[klass]

      cache[klass] = Rails.application.routes.named_routes.detect do |route|
        route.last.app.app == klass
      end.try(:first)
    end

    def mount_point
      Workarea::MountPoint.find(self)
    end

    def mounted?
      mount_point.present?
    end

    def mount_path
      return nil unless mounted?
      routes.url_helpers.root_path
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.13 lib/workarea/mount_point.rb
workarea-core-3.4.12 lib/workarea/mount_point.rb