Class: Serve::Rails::Mount

Inherits:
Object
  • Object
show all
Defined in:
lib/serve/rails/mount.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(route, root) ⇒ Mount

Returns a new instance of Mount.



6
7
8
9
# File 'lib/serve/rails/mount.rb', line 6

def initialize(route, root)
  @route, @root_path = route, root
  @view_helper_module_names = []
end

Instance Attribute Details

#root_pathObject (readonly)

Returns the value of attribute root_path.



4
5
6
# File 'lib/serve/rails/mount.rb', line 4

def root_path
  @root_path
end

#routeObject (readonly)

Returns the value of attribute route.



4
5
6
# File 'lib/serve/rails/mount.rb', line 4

def route
  @route
end

Instance Method Details

#append_view_helper(module_name) ⇒ Object

Appends to the collection of view helpers that will be made availabe to the DynamicHandler. These should be module names. They will be constantized in order to allow for re-loading in development mode.



15
16
17
# File 'lib/serve/rails/mount.rb', line 15

def append_view_helper(module_name)
  @view_helper_module_names << module_name
end

#connectionObject



19
20
21
# File 'lib/serve/rails/mount.rb', line 19

def connection
  @route == '/' ? '*path' : "#{@route}/*path"
end

#resolve_path(path) ⇒ Object



23
24
25
# File 'lib/serve/rails/mount.rb', line 23

def resolve_path(path)
  Serve.resolve_file(@root_path, path)
end

#view_helpersObject



27
28
29
30
31
32
33
34
35
# File 'lib/serve/rails/mount.rb', line 27

def view_helpers
  helpers = Module.new
  @view_helper_module_names.each do |module_name|
    helpers.module_eval do
      include module_name.constantize
    end
  end
  helpers
end