Class: Hobix::BaseStorage

Inherits:
BasePlugin show all
Defined in:
lib/hobix/base.rb

Overview

The BaseStorage class outlines the fundamental API for all storage plugins. Storage plugins are responsible for abstracting away entry queries and managing the loading of Entry objects. The goal being: cache as much as you can, be efficient and tidy.

Query Methods

find

Each of the query methods below uses the find method to perform its search. This method accepts a Hash of parameters. Please note that calling find without parameters will return all entries which qualify for placement on the front page.

all

Returns all entries. Searches find( :all => true )

lastn

Returns the last n entries which qualify for the front page.

inpath

Returns entries within a path which qualify for the front page.

after

Returns entries created after a given date.

before

Returns entries created before a given date.

within

Returns entries created between a start and end date.

Direct Known Subclasses

Storage::FileSys

Instance Method Summary collapse

Methods inherited from BasePlugin

inherited, start

Constructor Details

#initialize(weblog) ⇒ BaseStorage

Returns a new instance of BaseStorage.



87
88
89
# File 'lib/hobix/base.rb', line 87

def initialize( weblog )
    @link = weblog.link
end

Instance Method Details

#after(after, n = nil) ⇒ Object



113
114
115
# File 'lib/hobix/base.rb', line 113

def after( after, n = nil )
    find( :after => after, :lastn => n )
end

#allObject



104
105
106
# File 'lib/hobix/base.rb', line 104

def all
    find( :all => true )
end

#before(before, n = nil) ⇒ Object



116
117
118
# File 'lib/hobix/base.rb', line 116

def before( before, n = nil )
    find( :before => before, :lastn => n )
end

#default_entry(author) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/hobix/base.rb', line 91

def default_entry( author )
    Hobix::Entry.new do |e|
        e.id = default_entry_id 
        e.link = e.class.url_link e, @link, "html"
        e.created = Time.now
        e.modified = Time.now
        e.updated = Time.now
        e.title = "This Ghostly Message From the Slime Will Soon Vanish!"
        e.tagline = "A temporary message, a tingling sensation, Hobix is up!!"
        e.author = author
        e.content = Hobix::Entry.text_processor.new( "Welcome to Hobix!  Once you make your first blog post, this entry will disappear.  However, in the meantime, you can tweak the CSS of your blog until it suits your satisfaction and you have this bit of words to act as a place holder." )
    end
end

#default_entry_idObject



90
# File 'lib/hobix/base.rb', line 90

def default_entry_id; "hobix-default-entry"; end

#inpath(path, n = nil) ⇒ Object



110
111
112
# File 'lib/hobix/base.rb', line 110

def inpath( path, n = nil )
    find( :inpath => path, :lastn => n )
end

#lastn(n) ⇒ Object



107
108
109
# File 'lib/hobix/base.rb', line 107

def lastn( n )
    find( :lastn => ( n || 10 ) )
end

#match(expr) ⇒ Object



119
120
121
# File 'lib/hobix/base.rb', line 119

def match( expr )
    find( :match => expr )
end

#within(after, before) ⇒ Object



122
123
124
# File 'lib/hobix/base.rb', line 122

def within( after, before )
    find( :after => after, :before => before )
end