Class: Mascot::DirectoryCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/mascot/directory_collection.rb

Overview

Maps a directory of assets into a set of routes that correspond with the ‘path` root.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, assets:) ⇒ DirectoryCollection

Returns a new instance of DirectoryCollection.



7
8
9
10
# File 'lib/mascot/directory_collection.rb', line 7

def initialize(path: , assets:)
  @path = path
  @assets = assets
end

Instance Attribute Details

#assetsObject (readonly)

Returns the value of attribute assets.



5
6
7
# File 'lib/mascot/directory_collection.rb', line 5

def assets
  @assets
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/mascot/directory_collection.rb', line 5

def path
  @path
end

Instance Method Details

#mount(node) ⇒ Object



12
13
14
# File 'lib/mascot/directory_collection.rb', line 12

def mount(node)
  assets.each { |a| node.add path: asset_path_to_request_path(a), asset: a }
end