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

Action & Channel should be modules #23

Closed
3 tasks done
vladfaust opened this issue Apr 26, 2018 · 0 comments
Closed
3 tasks done

Action & Channel should be modules #23

vladfaust opened this issue Apr 26, 2018 · 0 comments
Assignees

Comments

@vladfaust
Copy link
Member

vladfaust commented Apr 26, 2018

Composition over inheritance!

Ideal code would be:

struct MyAction
  include Prism::Action
  include Prism::Params
  include Prism::Auth
  
  auth!

  params do
    param :foo, Int32
  end
  
  def call
    # ...
  end
end

That said, following must be implemented:

  • Prism::Action includes Callbacks and they do actually work (see Can't call re-defined method. crystal-lang/crystal#1104 (comment))
  • MyAction can be an abstract struct and callbacks should work in this case as well
  • Prism::Params and Prism::Auth included along with Prism::Action automatically inject those before callbacks Introduce Prism::Action::Params & Prism::Action::Auth, which is more straightforward IMO
@vladfaust vladfaust added this to the v0.2.0 milestone Apr 26, 2018
@vladfaust vladfaust self-assigned this Apr 26, 2018
@vladfaust vladfaust changed the title Action & Channels should be modules Action & Channel should be modules Apr 26, 2018
@vladfaust vladfaust removed this from the v0.2.0 milestone Apr 26, 2018
vladfaust added a commit that referenced this issue Aug 20, 2018
BREAKING CHANGE: extracted to external shard

Related to #23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant