From 040a3f5c31adcbb37c48d78ba86a0ab40853349e Mon Sep 17 00:00:00 2001 From: Omkar Moghe Date: Fri, 29 Mar 2024 16:50:15 -0700 Subject: [PATCH] cleanup --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 608b68b..0064306 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ If bundler is not being used to manage dependencies, install the gem by executin ## Why would I need this? -PortableExpressions can be a powerful tool when designing stateless components. It's useful when you want to transmit the actual _logic_ you want to run (i.e. an `Expression`) along with its inputs. By making your logic or procedure stateless, you can decouple services from one another in interesting and scalable ways. +`PortableExpressions` can be a powerful tool when designing stateless components. It's useful when you want to transmit the actual _logic_ you want to run (i.e. an `Expression`) along with its inputs. By making your logic or procedure stateless, you can decouple services from one another in interesting and scalable ways. Consider a serverless function (e.g. [AWS Lambda](https://aws.amazon.com/lambda/)) that adds 2 inputs together and some application code that calls it: @@ -38,7 +38,7 @@ def multiply(input1, input2) end ``` -But what happens as complexity increases, e.g. you want to run more steps? You could continue to define functions, but it would be a lot simpler if there was a way to tell the function what steps to run, the same way you pass it the inputs. That's where PortableExpressions come in handy: +But what happens as complexity increases, e.g. you want to run more steps? You could continue to define specific functions, but it would be a lot simpler if there was a way to tell the function what steps to run, the same way you tell it what the inputs are. Let's rewrite our function using `PortableExpressions`. ```ruby # Serverless function @@ -71,7 +71,9 @@ inputs = PortableExpressions::Environment.new( serverless_function_call(:run_expressions, multiply_step.to_json, inputs.to_json) #=> 9 ``` -This is an oversimplified example to illustrate the kind of code you can write when your logic or procedure is **stateless** and **portable**. Here we demonstrated arithmetic, but the `operator` can be any Ruby method that the `operands` respond to, which means your `Expressions` can do a lot more than just add or multiply numbers. +This is an oversimplified example to illustrate the kind of code you can write when your logic or procedure is **stateless** and **portable**. In your application, the inputs and procedure may come from different sources. + +We demonstrated arithmetic in our example, but the `operator` can be _any Ruby method_ that the `operands` respond to, which means your `Expressions` can do a lot more than just add or multiply numbers. See [example use cases](#example-use-cases) for more ideas.