Class: Laze::Store

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/laze/store.rb

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

Instance Method Summary collapse

Constructor Details

#initializeStore

: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)

Raises:



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

#eachObject

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_layoutObject

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_fileObject

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