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



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

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)         || []
  @options      = opts
end

Instance Attribute Details

#argsObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def args
  @args
end

#mount_pathObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def mount_path
  @mount_path
end

#mountedObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def mounted
  @mounted
end

#mounted_appObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def mounted_app
  @mounted_app
end

#optionsObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def options
  @options
end

#stackup_withObject

Since:

  • 0.1.2



49
50
51
# File 'lib/pancake/router.rb', line 49

def stackup_with
  @stackup_with
end

Instance Method Details

#mount!(route) ⇒ Object

Since:

  • 0.1.2



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pancake/router.rb', line 68

def mount!(route)
  app = nil
  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.partial
  route
end

#mounted?Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.2



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

def mounted?
  !!@mounted
end

#name(name = nil) ⇒ Object

Since:

  • 0.1.2



57
58
59
60
61
62
# File 'lib/pancake/router.rb', line 57

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