Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow inspecting operations #42

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

waiting-for-dev
Copy link
Owner

@waiting-for-dev waiting-for-dev commented Apr 14, 2021

Until now, once a WebPipe app had been initialized, there was no way
to get an operation by its plug name. This changes with this commit.
WebPipe#operations is now a hash mapping the plug name with the final
operation, which can be determined whether by being resolved or
injected.

require 'web_pipe'
require 'web_pipe/conn_support/builder'

class MyApp
  include WebPipe

  plug :hello do |conn|
    conn.set_response_body('Hello')
  end
end

conn = WebPipe::ConnSupport::Builder.call(Rack::MockRequest.env_for)
app = MyApp.new
app.operations[:hello].call(conn).response_body # => ['Hello']

Until now, once a `WebPipe` app had been initialized, there was no way
to get an operation by its plug name. This changes with this commit.
`WebPipe#operations` is now a hash mapping the plug name with the final
operation, which can be determined whether by being resolved or
injected.

```ruby
require 'web_pipe'
require 'web_pipe/conn_support/builder'

class MyApp
  include WebPipe

  plug :hello do |conn|
    conn.set_response_body('Hello')
  end
end

conn = WebPipe::ConnSupport::Builder.call(Rack::MockRequest.env_for)
app = MyApp.new
app.operations[:hello].call(conn).response_body # => ['Hello']
```
@waiting-for-dev waiting-for-dev force-pushed the waiting-for-dev/inspect_operations branch from d5da337 to 352001c Compare April 14, 2021 08:55
@waiting-for-dev waiting-for-dev merged commit 8b3e90b into master Apr 14, 2021
@waiting-for-dev waiting-for-dev deleted the waiting-for-dev/inspect_operations branch April 14, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant