Class: Noumenon::AssetRepository
- Inherits:
-
Object
- Object
- Noumenon::AssetRepository
- Defined in:
- lib/noumenon/asset_repository.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FileSystem
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Provides access to options set on initialization.
Instance Method Summary collapse
-
#get(path) ⇒ String?
Retrieves a static asset from the repository.
-
#initialize(options = {}) ⇒ AssetRepository
constructor
Create a new Repository instance.
-
#put(path, content) ⇒ Object
Saves a static asset to the repository.
-
#url_for(path) ⇒ String
Returns a URL for the specified asset, without checking for it’s existence.
Constructor Details
#initialize(options = {}) ⇒ AssetRepository
Create a new Repository instance.
12 13 14 |
# File 'lib/noumenon/asset_repository.rb', line 12 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Provides access to options set on initialization.
6 7 8 |
# File 'lib/noumenon/asset_repository.rb', line 6 def @options end |
Instance Method Details
#get(path) ⇒ String?
Retrieves a static asset from the repository. If the asset does not exist nil is returned.
30 31 32 |
# File 'lib/noumenon/asset_repository.rb', line 30 def get(path) not_supported "loading assets" end |
#put(path, content) ⇒ Object
Saves a static asset to the repository. To be saved the asset must have a file extension, to prevent problems with an entire directory being overridden by a single asset.
22 23 24 |
# File 'lib/noumenon/asset_repository.rb', line 22 def put(path, content) not_supported "saving assets" end |
#url_for(path) ⇒ String
Returns a URL for the specified asset, without checking for it’s existence.
This is most useful for repositories that save their assets to a CDN such as S3, and allows them to be directly accessed from there, instead of downloaded and then retransmitted.
41 42 43 |
# File 'lib/noumenon/asset_repository.rb', line 41 def url_for(path) File.join("/assets", path) end |