Class: Jekyll::Plugin
- Inherits:
-
Object
- Object
- Jekyll::Plugin
- Defined in:
- lib/jekyll/plugin.rb
Constant Summary collapse
- PRIORITIES =
{ :lowest => -100, :low => -10, :normal => 0, :high => 10, :highest => 100 }
Class Method Summary collapse
-
.<=>(other) ⇒ Object
Spaceship is priority [higher -> lower].
-
.descendants ⇒ Object
Fetch all the subclasses of this class and its subclasses’ subclasses.
-
.priority(priority = nil) ⇒ Object
Get or set the priority of this plugin.
-
.safe(safe = nil) ⇒ Object
Get or set the safety of this plugin.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Spaceship is priority [higher -> lower].
-
#initialize(config = {}) ⇒ Plugin
constructor
Initialize a new plugin.
Constructor Details
#initialize(config = {}) ⇒ Plugin
Initialize a new plugin. This should be overridden by the subclass.
config - The Hash of configuration options.
Returns a new instance.
73 74 75 |
# File 'lib/jekyll/plugin.rb', line 73 def initialize(config = {}) # no-op for default end |
Class Method Details
.<=>(other) ⇒ Object
Spaceship is priority [higher -> lower]
other - The class to be compared.
Returns -1, 0, 1.
55 56 57 |
# File 'lib/jekyll/plugin.rb', line 55 def self.<=>(other) PRIORITIES[other.priority] <=> PRIORITIES[self.priority] end |
.descendants ⇒ Object
Fetch all the subclasses of this class and its subclasses’ subclasses.
Returns an array of descendant classes.
12 13 14 15 16 17 18 |
# File 'lib/jekyll/plugin.rb', line 12 def self.descendants descendants = [] ObjectSpace.each_object(singleton_class) do |k| descendants.unshift k unless k == self end descendants end |
.priority(priority = nil) ⇒ Object
Get or set the priority of this plugin. When called without an argument it returns the priority. When an argument is given, it will set the priority.
priority - The Symbol priority (default: nil). Valid options are:
:lowest, :low, :normal, :high, :highest
Returns the Symbol priority.
28 29 30 31 32 33 34 |
# File 'lib/jekyll/plugin.rb', line 28 def self.priority(priority = nil) @priority ||= nil if priority && PRIORITIES.key?(priority) @priority = priority end @priority || :normal end |
.safe(safe = nil) ⇒ Object
Get or set the safety of this plugin. When called without an argument it returns the safety. When an argument is given, it will set the safety.
safe - The Boolean safety (default: nil).
Returns the safety Boolean.
43 44 45 46 47 48 |
# File 'lib/jekyll/plugin.rb', line 43 def self.safe(safe = nil) if safe @safe = safe end @safe || false end |
Instance Method Details
#<=>(other) ⇒ Object
Spaceship is priority [higher -> lower]
other - The class to be compared.
Returns -1, 0, 1.
64 65 66 |
# File 'lib/jekyll/plugin.rb', line 64 def <=>(other) self.class <=> other.class end |