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.5.27 lib/workarea/mount_point.rb
workarea-core-3.5.26 lib/workarea/mount_point.rb
workarea-core-3.4.45 lib/workarea/mount_point.rb
workarea-core-3.5.25 lib/workarea/mount_point.rb
workarea-core-3.5.23 lib/workarea/mount_point.rb
workarea-core-3.4.44 lib/workarea/mount_point.rb
workarea-core-3.5.22 lib/workarea/mount_point.rb
workarea-core-3.4.43 lib/workarea/mount_point.rb
workarea-core-3.5.21 lib/workarea/mount_point.rb
workarea-core-3.4.42 lib/workarea/mount_point.rb
workarea-core-3.5.20 lib/workarea/mount_point.rb
workarea-core-3.4.41 lib/workarea/mount_point.rb
workarea-core-3.5.19 lib/workarea/mount_point.rb
workarea-core-3.4.40 lib/workarea/mount_point.rb
workarea-core-3.5.18 lib/workarea/mount_point.rb
workarea-core-3.4.39 lib/workarea/mount_point.rb
workarea-core-3.5.17 lib/workarea/mount_point.rb
workarea-core-3.4.38 lib/workarea/mount_point.rb
workarea-core-3.5.16 lib/workarea/mount_point.rb
workarea-core-3.4.37 lib/workarea/mount_point.rb