Sha256: 9a37379a33ec4c380315b939ef3562ae40e85dadfbaa0163f31a70d62be9db79

Contents?: true

Size: 1019 Bytes

Versions: 4

Compression:

Stored size: 1019 Bytes

Contents

# frozen_string_literal: true

class UniformNotifier
  class Base
    class << self
      def active?
        false
      end

      def inline_notify(data)
        return unless active?

        # For compatibility to the old protocol
        data = { title: data } if data.is_a?(String)

        _inline_notify(data)
      end

      def out_of_channel_notify(data)
        return unless active?

        # For compatibility to the old protocol
        data = { title: data } if data.is_a?(String)

        _out_of_channel_notify(data)
      end

      protected

      def _inline_notify(data); end

      def _out_of_channel_notify(data); end

      def wrap_js_association(code, attributes = {})
        attributes = { type: 'text/javascript' }.merge(attributes || {})
        attributes_string = attributes.map { |k, v| "#{k}=#{v.to_s.inspect}" }.join(' ')

        <<~CODE
          <script #{attributes_string}>/*<![CDATA[*/
          #{code}
          /*]]>*/</script>
        CODE
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
uniform_notifier-1.16.0 lib/uniform_notifier/base.rb
uniform_notifier-1.15.0 lib/uniform_notifier/base.rb
uniform_notifier-1.14.2 lib/uniform_notifier/base.rb
uniform_notifier-1.14.1 lib/uniform_notifier/base.rb