Skip to content

Commit

Permalink
fucking syntax highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarmoghe committed Mar 28, 2024
1 parent cd5448d commit b25ff3a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ environment.evaluate(Variable.new("variable_a")) # => 2
> [!CAUTION]
> Ruby `symbols` are converted to `strings` when serialized to JSON, and remain `strings` when that JSON is parsed.
>
> ```ruby
> environment = Environment.new(foo: "bar")
>
> variable_foo = Variable.new(:foo)
> environment.evaluate(variable_foo) #=> "bar"
>
> variable_foo = PortableExpressions.from_json(variable_foo.to_json)
> environment.evaluate(variable_foo) #=> MissingVariableError
> ```
```ruby
environment = Environment.new(foo: "bar")

variable_foo = Variable.new(:foo)
environment.evaluate(variable_foo) #=> "bar"

variable_foo = PortableExpressions.from_json(variable_foo.to_json)
environment.evaluate(variable_foo) #=> MissingVariableError
```

### Serialization (to JSON)

Expand Down Expand Up @@ -276,14 +276,14 @@ File.write("user_owns_resource_and_has_permission.json", user_owns_resource_and_

> [!TIP]
> These examples demonstrate portability via JSON files, but we can just as easily serve the policy directly to anyone who needs it via some HTTP controller:
>
> ```ruby
> # E.g. Rails via an `ActionController`
> render json: user_owns_resource_and_has_permission.as_json, :ok
>
> # Elsewhere, in the requesting service
> user_owns_resource_and_has_permission = PortableExpressions.from_json(response.body.to_s)
> ```
```ruby
# E.g. Rails via an `ActionController`
render json: user_owns_resource_and_has_permission.as_json, :ok

# Elsewhere, in the requesting service
user_owns_resource_and_has_permission = PortableExpressions.from_json(response.body.to_s)
```

Then, some consumer with access to the user's permissions and context around the requested `resource` and `action` can execute the policy.

Expand Down

0 comments on commit b25ff3a

Please sign in to comment.