Class: Ars::Medium::TestMethods::RackChanneler
- Inherits:
-
Object
- Object
- Ars::Medium::TestMethods::RackChanneler
- Defined in:
- lib/ars/medium/test_methods.rb
Defined Under Namespace
Classes: RHash
Instance Attribute Summary collapse
-
#path_map ⇒ Object
Returns the value of attribute path_map.
Instance Method Summary collapse
- #body ⇒ Object
- #call(env) ⇒ Object
- #focus(medium) ⇒ Object
- #headers ⇒ Object
-
#initialize ⇒ RackChanneler
constructor
A new instance of RackChanneler.
- #path_regex(path) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize ⇒ RackChanneler
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_map ⇒ Object
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
#body ⇒ Object
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 |
#headers ⇒ Object
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 |
#status ⇒ Object
45 46 47 |
# File 'lib/ars/medium/test_methods.rb', line 45 def status 200 end |