Sha256: 54f9e15390d7bc74d9d35b22dbe03ea7230e59640a7d8b9e7d90c935778c1d92

Contents?: true

Size: 1.82 KB

Versions: 5

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module CableReady
  module ViewHelper
    include CableReady::Compoundable
    include CableReady::StreamIdentifier

    def stream_from(...)
      warn "DEPRECATED: please use `cable_ready_stream_from` instead. The `stream_from` view helper will be removed from a future version of CableReady 5"

      cable_ready_stream_from(...)
    end

    def updates_for(...)
      warn "DEPRECATED: please use `cable_ready_updates_for` instead. The `updates_for` view helper will be removed from a future version of CableReady 5"

      cable_ready_updates_for(...)
    end

    def updates_for_if(...)
      warn "DEPRECATED: please use `cable_ready_updates_for_if` instead. The `updates_for_if` view helper will be removed from a future version of CableReady 5"

      cable_ready_updates_for_if(...)
    end

    def cable_ready_stream_from(*keys, html_options: {})
      tag.cable_ready_stream_from(**build_options(*keys, html_options))
    end

    def cable_ready_updates_for(*keys, url: nil, debounce: nil, only: nil, ignore_inner_updates: false, html_options: {}, &block)
      options = build_options(*keys, html_options)
      options[:url] = url if url
      options[:debounce] = debounce if debounce
      options[:only] = only if only
      options[:"ignore-inner-updates"] = "" if ignore_inner_updates
      tag.cable_ready_updates_for(**options) { capture(&block) }
    end

    def cable_ready_updates_for_if(condition, *keys, **options, &block)
      if condition
        cable_ready_updates_for(*keys, **options, &block)
      else
        capture(&block)
      end
    end

    def cable_car
      CableReady::CableCar.instance
    end

    private

    def build_options(*keys, html_options)
      keys.select!(&:itself)
      {identifier: signed_stream_identifier(compound(keys))}.merge(html_options)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cable_ready-5.0.1 app/helpers/cable_ready/view_helper.rb
cable_ready-5.0.0 app/helpers/cable_ready/view_helper.rb
cable_ready-5.0.0.rc2 app/helpers/cable_ready/view_helper.rb
cable_ready-5.0.0.rc1 app/helpers/cable_ready/view_helper.rb
cable_ready-5.0.0.pre10 app/helpers/cable_ready/view_helper.rb