pabloh / pathway Goto Github PK
View Code? Open in Web Editor NEWDefine your business logic in simple steps
License: MIT License
Define your business logic in simple steps
License: MIT License
When using a DB transaction allow to define steps to run within an after_commit
Sequel
block:
# ...
process do
step :validate
step :fetch_model
transaction do
step :save_model
after_commit do
step :send_emails
step :issue_notifications
end
end
end
# ...
because of this line:
https://github.com/pabloh/pathway/blob/master/lib/pathway/plugins/simple_auth.rb#L18
I'm not sure why we need a check like this so I didn't know if removing the line would cause issue. Basically I want to perform an action on multiple objects but before I do that, I want to make sure each object in the array has permission to perform the object. So it either fails all at once or processes everything. So like:
process do
step :validate
set :fetch_models, to: :alerts
step :authorize, using: :alerts
step :some_action
set :show_all
end
Add a plugin architecture, based to the one found in roda, to allow cherry picking bits of functionally into your operation.
Inside the documentation, in the Error objects section, the example code suggest write something like this...
# frozen_string_literal: true
require "pathway"
class CreateNugget < Pathway::Operation
def call(input)
error(type: :validation, message: 'Invalid input', details: [])
end
end
CreateNugget.new.call("something")
raise the following error:
$ ruby app.rb
Traceback (most recent call last):
4: from app.rb:11:in `<main>'
3: from app.rb:17:in `call'
2: from /home/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pathway-0.11.1/lib/pathway.rb:116:in `error'
1: from /home/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pathway-0.11.1/lib/pathway.rb:116:in `new'
/home/user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/pathway-0.11.1/lib/pathway.rb:40:in `initialize': undefined method `to_sym' for {:type=>:validation, :message=>"Invalid input", :details=>[]}:Hash (NoMethodError)
Did you mean? to_s
to_set
Removing the :type key and leaving only the value as first param the code run as normal
# frozen_string_literal: true
require "pathway"
class CreateNugget < Pathway::Operation
def call(input)
error(:validation, message: 'Invalid input', details: [])
end
end
result = CreateNugget.new.call("something")
if result.failure?
result.error.type #=> validation
result.error.message #=> "Invalid input"
end
I don't know if I was forgot something or if this a outdated section in the README.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.