Code Monkey home page Code Monkey logo

activefunction's People

Contributors

nerbyk avatar

Stargazers

 avatar

Forkers

dmitrybarskov

activefunction's Issues

Make `callbacks` plugin `:only` option to accept symbols

Current implementation supports only %w() that is suboptimal in terms of memory efficiency and performance. Utilizing symbols instead of strings within the %w() would not only minimize memory footprint but also streamline callback execution, as the underlying callback mechanism employs the send method which inherently transforms strings into symbols.

Extract `Callbacks` to `activefunction-core`

Extract ActiveFunction::Functions::Callbacks to activefunction-core gem to hook any method using callbackable DSL method

Example:

class MyController
  include ActiveFunctionCore::Plugins::Callbacks

  callbackable :process
  callbackable :serialize

  before_process :do_something

  def process
    # Action logic here
  end

  private

  def do_something
    # Callback logic here
  end
end

Restructure gem to embrace serverless design principles

Problem

The current structure of the gem does not conform to Serverless Design Principles. The architecture lacks modularity and scalability, handling multiple scenarios within a single lambda function.

Core Issues:

  • Modularity: Absence of a modular structure within the API complicates code maintenance and scalability.
  • Serverless Integration: Lack of adherence to serverless design principles impedes smooth integration within serverless environments.

Add Nested `.permit(users: [])` to Permit all parameters

There is no way to permit all nested params. It could be great to make it possible to pass [] for permitting all nested params

class AppFunction < ActiveFunction::Base
   def index
      params.permit(data: []).to_h # =>  { data: { id: 1, text: "foobar" } }
   end
end

AppFunction.process(:index, { data: { id: 1, text: "foobar" } })

Add ActiveFunction::Functions::Rescuable

Implement #rescue_from callback for custom exception handling

class SomeFunction < ActiveFunction::Base
  rescue_from InvalidRequestFormatError do |exception| 
     render json: exception.message, status: 422  
  end
end

Make Callbacks inheritable

Current implementation of ActiveFunction::Functions::Callbacks doesn't provide callbacks inheritance due to singleton class instance variable __callbacks initializing logic https://github.com/DanilMaximov/activefunction/blob/10f282da4a29c32cfada967956c97377935376c9/lib/active_function/functions/callbacks.rb#L57-L61

Expected behavior:

class ApplicationFunction < ActiveFunction::Base
  before_action :set_current_user

  def set_current_user
     @current_user = 'current_user'
  end
end

class SomeFunction < ApplicationFunction
end

fn = SomeFunction.new
fn.dispatch(...)
fn.instance_variable_get(:@current_user) # => 'current_user'

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.