Coder Social home page Coder Social logo

pathway's Issues

Improve documentation

  • Document core API and concepts
  • Explain plugin architecture
  • Document every plugin separately
  • Provide common examples for core features and plugins
  • Document testing recipes and recommendations using at least RSpec

authorize, using: does not allow for array input

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 support for plugins

Add a plugin architecture, based to the one found in roda, to allow cherry picking bits of functionally into your operation.

helper "error" raises error when params include :type key

Inside the documentation, in the Error objects section, the example code suggest write something like this...

Code with error

# 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

Code without error

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.