Module: MemoRack::Plugin
- Included in:
- PageInfo
- Defined in:
- lib/memorack/plugin.rb
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
プラグインの優先順位を比較する.
-
#[](key) ⇒ Object
ファイル拡張子からプラグインをみつける.
- #extnames ⇒ Object
-
#inherited(subclass) ⇒ Object
サブクラスが追加されたらプラグインに登録する.
- #member?(key, ext = nil) ⇒ Boolean
-
#plugins ⇒ Object
プラグイン一覧.
-
#priority ⇒ Object
優先順位.
Instance Method Details
#<=>(other) ⇒ Object
プラグインの優先順位を比較する
27 28 29 30 31 32 |
# File 'lib/memorack/plugin.rb', line 27 def <=>(other) r = - (self.priority <=> other.priority) return r unless r == 0 self.to_s <=> other.to_s end |
#[](key) ⇒ Object
ファイル拡張子からプラグインをみつける
43 44 45 46 47 48 49 50 51 |
# File 'lib/memorack/plugin.rb', line 43 def [](key) ext = File.extname(key)[1..-1] plugins.each { |plugin| return plugin if plugin.member?(key, ext) } nil end |
#extnames ⇒ Object
38 39 40 |
# File 'lib/memorack/plugin.rb', line 38 def extnames [] end |
#inherited(subclass) ⇒ Object
サブクラスが追加されたらプラグインに登録する
12 13 14 |
# File 'lib/memorack/plugin.rb', line 12 def inherited(subclass) plugins << subclass end |
#member?(key, ext = nil) ⇒ Boolean
34 35 36 |
# File 'lib/memorack/plugin.rb', line 34 def member?(key, ext = nil) extnames.member?(ext) end |
#plugins ⇒ Object
プラグイン一覧
17 18 19 |
# File 'lib/memorack/plugin.rb', line 17 def plugins @plugins ||= SortedSet.new end |
#priority ⇒ Object
優先順位
22 23 24 |
# File 'lib/memorack/plugin.rb', line 22 def priority 1 end |