Class: Ars::Medium::TestMethods::RackChanneler

Inherits:
Object
  • Object
show all
Defined in:
lib/ars/medium/test_methods.rb

Defined Under Namespace

Classes: RHash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRackChanneler

Returns a new instance of RackChanneler.



25
26
27
# File 'lib/ars/medium/test_methods.rb', line 25

def initialize
  @path_map = RHash.new
end

Instance Attribute Details

#path_mapObject

Returns the value of attribute path_map.



17
18
19
# File 'lib/ars/medium/test_methods.rb', line 17

def path_map
  @path_map
end

Instance Method Details

#bodyObject



53
54
55
# File 'lib/ars/medium/test_methods.rb', line 53

def body
  []
end

#call(env) ⇒ Object



41
42
43
# File 'lib/ars/medium/test_methods.rb', line 41

def call(env)
  [status, headers, body]
end

#focus(medium) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ars/medium/test_methods.rb', line 29

def focus(medium)
  [:collection_path, :resource_path].each do |path|
    path = medium.send(path)
    path_regex = path_regex path
    path_map[path_regex] = { medium: medium, path: path, regex: path_regex }
  end
end

#headersObject



49
50
51
# File 'lib/ars/medium/test_methods.rb', line 49

def headers
  {}
end

#path_regex(path) ⇒ Object



37
38
39
# File 'lib/ars/medium/test_methods.rb', line 37

def path_regex(path)
  Regexp.new("^/#{path.gsub(/\:([^\/]+)/, '(?<\1>[^\/]+)')}$")
end

#statusObject



45
46
47
# File 'lib/ars/medium/test_methods.rb', line 45

def status
  200
end