Class: Pancake::Router::MountedApplication

Inherits:
Object
  • Object
show all
Defined in:
lib/pancake/router.rb

Overview

Since:

  • 0.1.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mounted_app, mount_path, opts = {}) ⇒ MountedApplication

Returns a new instance of MountedApplication.

Since:

  • 0.1.2



53
54
55
56
57
58
59
# File 'lib/pancake/router.rb', line 53

def initialize(mounted_app, mount_path, opts = {})
  @mounted_app, @mount_path = mounted_app, mount_path
  @stackup_with = opts.delete(:_stackup)      || :stackup
  @args         = opts.delete(:_args)         || []
  @exact_match  = opts.delete(:_exact_match)  || false
  @options      = opts
end

Instance Attribute Details

#argsObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def args
  @args
end

#mount_pathObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def mount_path
  @mount_path
end

#mountedObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def mounted
  @mounted
end

#mounted_appObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def mounted_app
  @mounted_app
end

#optionsObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def options
  @options
end

#stackup_withObject

Since:

  • 0.1.2



52
53
54
# File 'lib/pancake/router.rb', line 52

def stackup_with
  @stackup_with
end

Instance Method Details

#exact_match?Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.2



72
73
74
# File 'lib/pancake/router.rb', line 72

def exact_match?
  !!@exact_match
end

#mount!(route) ⇒ Object

Since:

  • 0.1.2



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/pancake/router.rb', line 76

def mount!(route)
  app = nil
  route.consuming = true
  route.match_partially! unless exact_match?
  if mounted_app.respond_to?(stackup_with)
    app = mounted_app.send(stackup_with, *args)
  else
    app = mounted_app
  end
  route.to(app)
  route.name(@name) if @name
  route
end

#mounted?Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.2



68
69
70
# File 'lib/pancake/router.rb', line 68

def mounted?
  !!@mounted
end

#name(name = nil) ⇒ Object

Since:

  • 0.1.2



61
62
63
64
65
66
# File 'lib/pancake/router.rb', line 61

def name(name = nil)
  unless name.nil?
    @name = name
  end
  @name
end