Module: Hyde::DSL::PathMethods
- Included in:
- PathContext
- Defined in:
- lib/hyde/dsl/methods_path.rb
Overview
Common path methods
Instance Method Summary collapse
-
#filter(&block) {|request| ... } ⇒ Object
Add a filter to the path.
-
#index(index) ⇒ Object
Set path index.
-
#plugin(filename) ⇒ Object
Include an application as a child of path.
-
#postprocess(&block) {|request, response| ... } ⇒ Object
Add a postprocessor to the path.
-
#preprocess(&block) {|request| ... } ⇒ Object
Add a preprocessor to the path.
-
#remap(path) ⇒ Object
Set root path (without appending matched part).
-
#root(path) ⇒ Object
Set root path (appends matched part of the path).
Instance Method Details
#filter(&block) {|request| ... } ⇒ Object
Add a filter to the path. Blocks path access if a filter returns false.
55 56 57 58 |
# File 'lib/hyde/dsl/methods_path.rb', line 55 def filter(&block) @origin.filter(&block) block end |
#index(index) ⇒ Object
Set path index
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hyde/dsl/methods_path.rb', line 10 def index(index) case index when Array @origin.properties['index'] = index when String @origin.properties['index'] = [index] else raise ArgumentError, "index should be an Array or a String" end end |
#plugin(filename) ⇒ Object
Include an application as a child of path.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hyde/dsl/methods_path.rb', line 62 def plugin(filename) self.define_singleton_method(:run) do |object| unless object.is_a? Hyde::Node raise ArgumentError, "not a node instance or subclass instance" end object end @origin.children.append(self.instance_eval(File.read(filename))) self.singleton_class.undef_method :run end |
#postprocess(&block) {|request, response| ... } ⇒ Object
Add a postprocessor to the path.
46 47 48 49 |
# File 'lib/hyde/dsl/methods_path.rb', line 46 def postprocess(&block) @origin.postprocess(&block) block end |
#preprocess(&block) {|request| ... } ⇒ Object
Add a preprocessor to the path. Does not modify path execution.
37 38 39 40 |
# File 'lib/hyde/dsl/methods_path.rb', line 37 def preprocess(&block) @origin.preprocess(&block) block end |
#remap(path) ⇒ Object
Set root path (without appending matched part).
29 30 31 |
# File 'lib/hyde/dsl/methods_path.rb', line 29 def remap(path) @origin.remap = path end |