From 28c134ddb8da8ea938a392dcdca679391179b84a Mon Sep 17 00:00:00 2001 From: Alexander Senko Date: Wed, 7 Feb 2024 02:41:58 +0700 Subject: [PATCH] Integration with `Turbo::Broadcastable` Overriding defaults for Turbo broadcast jobs allows one to get decorated objects in model partials by default. Resolves drapergem/draper#910. Requires drapergem/draper#928. --- lib/draper/decoratable.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/draper/decoratable.rb b/lib/draper/decoratable.rb index f8ecde81..752d31b8 100644 --- a/lib/draper/decoratable.rb +++ b/lib/draper/decoratable.rb @@ -1,5 +1,4 @@ require 'draper/decoratable/equality' -require 'draper/compatibility/broadcastable' module Draper # Provides shortcuts to decorate objects directly, so you can do @@ -15,7 +14,10 @@ module Decoratable autoload :CollectionProxy, 'draper/decoratable/collection_proxy' included do - prepend Draper::Compatibility::Broadcastable if defined? Turbo::Broadcastable + if defined? Turbo::Broadcastable + require_relative 'compatibility/broadcastable' + prepend Compatibility::Broadcastable + end end # Decorates the object using the inferred {#decorator_class}.