Module: Hyde::DSL::PathMethods

Included in:
PathBinding
Defined in:
lib/hyde/dsl/path_methods.rb

Overview

Common path methods

Instance Method Summary collapse

Instance Method Details

#filter(&block) {|request| ... } ⇒ Object

Add a filter to the path. Blocks path access if a filter returns false.

Parameters:

  • block (#call)

Yield Parameters:



55
56
57
58
# File 'lib/hyde/dsl/path_methods.rb', line 55

def filter(&block)
  @origin.filter(&block)
  block
end

#index(index) ⇒ Object

Set path index

Parameters:

  • index (Array, String)


10
11
12
13
14
15
16
17
18
19
# File 'lib/hyde/dsl/path_methods.rb', line 10

def index(index)
  case index
  when Array
    @origin.properties['index'] = index
  when String
    @origin.properties['index'] = [index]
  else
    raise StandardError, "index should be an Array or a String"
  end
end

#postprocess(&block) {|request, response| ... } ⇒ Object

Add a postprocessor to the path.

Parameters:

  • block (#call)

Yield Parameters:



46
47
48
49
# File 'lib/hyde/dsl/path_methods.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.

Parameters:

  • block (#call)

Yield Parameters:



37
38
39
40
# File 'lib/hyde/dsl/path_methods.rb', line 37

def preprocess(&block)
  @origin.preprocess(&block)
  block
end

#remap(path) ⇒ Object

Set root path (without appending matched part).

Parameters:

  • path (String)

    ath [String



29
30
31
# File 'lib/hyde/dsl/path_methods.rb', line 29

def remap(path)
  @origin.remap = path
end

#root(path) ⇒ Object

Set root path (appends matched part of the path).

Parameters:

  • path (String)

    ath [String



23
24
25
# File 'lib/hyde/dsl/path_methods.rb', line 23

def root(path)
  @origin.root = path
end