From 79dd7f85720d2402634304530d446f24b920839d Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Tue, 12 Jul 2022 16:34:53 -0500 Subject: Add: scopes-and-bindings talk --- scopes/lspace.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scopes/lspace.rb (limited to 'scopes/lspace.rb') diff --git a/scopes/lspace.rb b/scopes/lspace.rb new file mode 100755 index 0000000..cf027e1 --- /dev/null +++ b/scopes/lspace.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'lspace' + +def log(str) + puts "#{LSpace[:log_prefix]}: #{str}" +end + +def handle_request(req) + LSpace.with(log_prefix: "handling request") do + log Time.now + log req[:status] + log req[:body] + end + + Lspace.with(log_prefix: "app") do + log "request handled" + end +end + +handle_request({status: 200, body: "success!"}) -- cgit v1.2.3