Class: Stasis::Ignore
Instance Method Summary collapse
-
#before_render ⇒ Object
This event triggers before each file renders.
-
#ignore(*array) ⇒ Object
This method is bound to all controllers.
-
#initialize(stasis) ⇒ Ignore
constructor
A new instance of Ignore.
-
#reset ⇒ Object
This event resets all instance variables.
Methods inherited from Plugin
#_match_key?, _priority, #_within?, inherited, plugins, priority
Constructor Details
#initialize(stasis) ⇒ Ignore
Returns a new instance of Ignore.
8 9 10 11 |
# File 'lib/stasis/plugins/ignore.rb', line 8 def initialize(stasis) @stasis = stasis reset end |
Instance Method Details
#before_render ⇒ Object
This event triggers before each file renders. Rejects any ‘paths` that are included in the `@ignore` `Array`.
15 16 17 18 19 20 21 22 |
# File 'lib/stasis/plugins/ignore.rb', line 15 def before_render matches = _match_key?(@ignore, @stasis.path) matches.each do |group| group.each do |path| @stasis.path = nil if _within?(path) end end end |
#ignore(*array) ⇒ Object
This method is bound to all controllers. Adds an ‘Array` of paths to the `@ignore` `Array`.
26 27 28 29 30 31 32 33 34 |
# File 'lib/stasis/plugins/ignore.rb', line 26 def ignore(*array) array.each do |path| path = @stasis.controller._resolve(path) if path @ignore[path] ||= [] @ignore[path] << @stasis.path end end end |
#reset ⇒ Object
This event resets all instance variables.
37 38 39 |
# File 'lib/stasis/plugins/ignore.rb', line 37 def reset @ignore = {} end |