Trailblazer v2.0.0 Release Notes

  • All old semantics will be available via trailblazer-compat.

    • ✂ Removed Operation::run as it was a bad decision. Raising an exception on invalid is a very test-specific scenario and shouldn't have been handled in the core doce.
    • ✂ Removed Operation::present, since you can simply call Operation::new (without builders) or Operation::build_operation (with builders).
    • ✂ Removed Operation::valid?. This is in the result object via result.success?.
    • ✂ Removed Operation#errors. This is in the result object via result[:errors] if the operation was invalid.
    • Removed the private option :raise_on_invalid. Use Contract::Raise instead, if you need it in tests.

    • ✂ Removed Operation::contract (without args). Please use Operation::["contract.default.class"].

    • ✂ Removed Operation::callbacks (without args). Please use Operation::["callback.<name>.class"].

    • ✂ Removed Operation::contract_class. Please use Operation::["contract.default.class"].

    • ✂ Removed Operation::contract_class=. Please use Operation::["contract.default.class"]=. Doesn't inherit.

    Model

    • The model method doesn't exist anymore, use self["model"] or write your own.
    • :find_by diverts to left track.
    • :create is :new now.

    🏗 Builder

    • 🏗 It's include Builder now, not extend Builder.
    • 🏗 builds now receives one options hash.

    Policy

    • 👻 No exception anymore, but Operation#["policy.result"].
    • Access the current user via self["current_user"] now.
    • 💅 Policy is Policy::Pundit now as Policy is Trailblazer's (upcoming) authorization style.

    Representer

    • ✂ Removed Operation::representer_class. Please use Operation::["representer.class"].
    • ✂ Removed Operation::representer_class=. Please use Operation::["representer.class"]=.
    • 📜 You can now have any number of named representers: Operation.representer :parser, ParsingRepresenter.
    • Automatic infering of the representer from a contract is not so automatic anymore. This feature was barely used and is now available via include Representer::InferFromContract.
    • 👍 Reform 2.0 is not supported in Representer anymore, meaning you can't automatically infer representers from 2.0 contracts. Reform 2.0 works with all remaining components.
    • ✂ Removed Operation::contract_class. Please use Operation::["contract.default.class"].
    • ✂ Removed Operation::contract_class=. Please use Operation::["contract.default.class"]=. Doesn't inherit.

    Callback

    • ✂ Removed Operation::Dispatch, it's called Operation::Callback.

    Collection

    • ✂ Removed Operation::Collection. Please use Operation::present.

    Controller

    Contract

    • 0️⃣ You can't call Create.().contract anymore. The contract instance(s) are available through the Result object via ["contract.default"].
    • ✂ Removed the deprecation for validate, signature is (params[, model, options, contract_class]).
    • ✂ Removed the deprecation for contract, signature is ([model, options, contract_class]).