Giter Site home page Giter Site logo

dryer's People

Contributors

dangerdawson avatar layonferreira avatar

Watchers

 avatar  avatar  avatar

dryer's Issues

Custom args

So say we have the following situation:

class Variant
  cast: stock_check, class_name: StockCheck
end

class StockCheck
  cast: update_products, class_name: UpdateProduct

  def call
    update_products.call  
  end
end

class UpdateProduct
  def call
    variant.in_stock_cache = true
  end
end

The question I have is how do we get variant down to UpdateProduct, as it will be passed the caster object ( I have renamed the sender object to caster )

We could do this:
1.

class UpdateProduct
  include Dryer::Cast::Target
  def call
    caster.variant.in_stock_cache = true
  end
end

or
2.

class UpdateProduct
  include Dryer::Cast::Target
  delegate :variant to :caster
  def call
    variant.in_stock_cache = true
  end
end

or
3.

class UpdateProduct
  include Dryer::Cast.target(:variant)
  def call
    variant.in_stock_cache = true
  end
end

In the first 2 we would have to make sure that the object we sent to UpdateProduct.new() responded to variant, for option 3 we would have to call UpdateProduct.new with variant as a param

Hence for all of them we would need the framework to do some magic on the caster side e.g

class StockCheck
  cast: update_products, class_name: UpdateProduct, with: [:variant]

  def call
    update_products.call  
  end

  private

  def variant
    caster.variant
  end
end

Do you see the problem?

TODOS

  • ~~ change dryer_delegate to cast ~~
  • ~~change Dryer::Delegate to ``Dryer::Cast~~
  • Find better names for Dryer::Delegate::Send and Dryer::DelegateTarget
  • Make sure Dryer::Delegate::Send can be included without arguments
  • We need a way to retrieve cast methods eg: .cast_targets || .cast_methods
  • Add method ```cast_private```

see [(https://github.com//pull/4)]

Allow nested casts

cast_private :product_parts_updater, class_name: "StockCheck::InStockCache::Update" do
  cast_private :model, class_name: "InStockCache::ProductPart"
end

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.