Class: Lifer::Selection
- Inherits:
-
Collection
- Object
- Collection
- Lifer::Selection
- Defined in:
- lib/lifer/selection.rb
Overview
A selection is a group of entries that belong to any collection. Lifer includes some selection classes by default, but the intent here is to let users bring their own selections.
A selection subclass can be added to the Lifer project as a Ruby file. Any
detected Ruby files are dynamically loaded when Lifer::Brain is initialized.
Implementing a selection is simple. Just implement the #entries method and
provide a name. The #entries method can be used to filter down
Lifer.entry_manifest in whichever way one needs. To see examples of this,
check out the source code of any of the included selections.
Direct Known Subclasses
Defined Under Namespace
Classes: AllMarkdown, IncludedInFeeds
Class Attribute Summary collapse
-
.name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.generate ⇒ Lifer::Selection
The constructor method for selections.
Instance Method Summary collapse
-
#entries ⇒ Object
The
#entriesmethod should be implemented on every selection subclass. -
#setting ⇒ String, ...
A getter for selection settings.
Class Attribute Details
.name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/lifer/selection.rb', line 15 def name @name end |
Class Method Details
.generate ⇒ Lifer::Selection
The constructor method for selections. Unlike collections:
1. Selections never have a unique instance name. (There is only one
instance of each selection, and it's inherited from the class.)
2. Selections never have a directory. Selections are virtual,
pseudo-collections that paste together entries across collections.
Thus, the generator method here takes no arguments.
27 28 29 30 31 |
# File 'lib/lifer/selection.rb', line 27 def generate selection = new(name: name, directory: nil) Lifer.register_settings name selection end |
Instance Method Details
#entries ⇒ Object
The #entries method should be implemented on every selection subclass.
49 50 51 |
# File 'lib/lifer/selection.rb', line 49 def entries raise NotImplementedError, I18n.t("selection.entries_not_implemented") end |
#setting ⇒ String, ...
A getter for selection settings. See Lifer::Collection#setting for more
information.
62 63 64 |
# File 'lib/lifer/selection.rb', line 62 def setting(...) super(...) end |