Class: Laze::Store
Constant Summary collapse
- StoreException =
Generic exception to be raised for store-specific exceptions.
Class.new(Exception)
- FileSystemException =
Exception for when interacting with the filesystem goes bad.
Class.new(StoreException)
Class Method Summary collapse
-
.find(kind) ⇒ Object
Find a storage engine by name and return its class.
-
.inherited(child) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#each ⇒ Object
Loop over all the items in the current project and yield them to the block.
-
#find_layout ⇒ Object
Return a new instance of Layout by finding a layout by the given name in the current project.
-
#initialize ⇒ Store
constructor
:nodoc:.
-
#read_template_file ⇒ Object
Return the contents of any project file.
Constructor Details
#initialize ⇒ Store
:nodoc:
29 30 31 |
# File 'lib/laze/store.rb', line 29 def initialize #:nodoc: Liquid::Template.file_system = self end |
Class Method Details
.find(kind) ⇒ Object
Find a storage engine by name and return its class.
When loading Laze::Stores::Filesystem
you would call:
Store.find(:filesystem)
19 20 21 22 23 |
# File 'lib/laze/store.rb', line 19 def self.find(kind) stores = @stores.select { |s| s.name.to_s.split('::').last.downcase.to_sym == kind } raise StoreException, 'No such store.' unless stores.any? stores.first end |
.inherited(child) ⇒ Object
:nodoc:
25 26 27 |
# File 'lib/laze/store.rb', line 25 def self.inherited(child) #:nodoc: @stores << child end |
Instance Method Details
#each ⇒ Object
Loop over all the items in the current project and yield them to the block.
35 36 37 |
# File 'lib/laze/store.rb', line 35 def each raise 'This is a generic store. Please use a subclass.' end |
#find_layout ⇒ Object
Return a new instance of Layout by finding a layout by the given name in the current project.
41 42 43 |
# File 'lib/laze/store.rb', line 41 def find_layout raise 'This is a generic store. Please use a subclass.' end |
#read_template_file ⇒ Object
Return the contents of any project file. This method is also used by the Liquid templating engine to read includes.
47 48 49 |
# File 'lib/laze/store.rb', line 47 def read_template_file raise 'This is a generic store. Please use a subclass.' end |