Module: ShamRack::Registration
- Included in:
- ShamRack
- Defined in:
- lib/sham_rack/registration.rb
Constant Summary collapse
- ADDRESS_PATTERN =
/^[a-z0-9-]+(\.[a-z0-9-]+)*$/i
Instance Method Summary collapse
- #application_for(address, port = nil) ⇒ Object
- #at(address, port = nil, &app_block) ⇒ Object
- #unmount_all ⇒ Object
Instance Method Details
#application_for(address, port = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/sham_rack/registration.rb', line 22 def application_for(address, port = nil) port ||= Net::HTTP.default_port mount_point_for(address, port).app.tap do |app| return app unless app.nil? unless ShamRack.network_connections_allowed? raise NetworkConnectionPrevented, "connection to #{address}:#{port} not allowed" end end end |
#at(address, port = nil, &app_block) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/sham_rack/registration.rb', line 13 def at(address, port = nil, &app_block) mount_point = mount_point_for(address, port) if app_block mount_point.mount(app_block) else mount_point end end |
#unmount_all ⇒ Object
9 10 11 |
# File 'lib/sham_rack/registration.rb', line 9 def unmount_all registry.clear end |