Sha256: c78b1da1ff63a19416d08a20a5d6ed2b28a148e1d8a91ccdf5491e8c3841e667

Contents?: true

Size: 721 Bytes

Versions: 21

Compression:

Stored size: 721 Bytes

Contents

class String
  # include ReactiveTags

  alias :__old_plus :+
  if RUBY_PLATFORM != 'opal'
    alias :__old_concat :<<
  end
  # alias :concat :__old_concat

  # In volt, we want a value + reactive strings to return a reactive string.  So we
  # over-ride + to check for when we are adding a reactive string to a string.
  def +(val)
    result = __old_plus(val.cur)
    if val.reactive? && !result.reactive?
      result = ReactiveValue.new(result)
    end

    return result
  end

  if RUBY_PLATFORM != 'opal'
    def <<(val)
      if val.reactive?
        raise "Cannot append a reactive string to non-reactive string.  Use + instead"
      end
      result = __old_concat(val)

      return result
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
volt-0.7.23 lib/volt/reactive/string_extensions.rb
volt-0.7.22 lib/volt/reactive/string_extensions.rb
volt-0.7.21 lib/volt/reactive/string_extensions.rb
volt-0.7.20 lib/volt/reactive/string_extensions.rb
volt-0.7.19 lib/volt/reactive/string_extensions.rb
volt-0.7.18 lib/volt/reactive/string_extensions.rb
volt-0.7.17 lib/volt/reactive/string_extensions.rb
volt-0.7.16 lib/volt/reactive/string_extensions.rb
volt-0.7.15 lib/volt/reactive/string_extensions.rb
volt-0.7.14 lib/volt/reactive/string_extensions.rb
volt-0.7.13 lib/volt/reactive/string_extensions.rb
volt-0.7.12 lib/volt/reactive/string_extensions.rb
volt-0.7.10 lib/volt/reactive/string_extensions.rb
volt-0.7.9 lib/volt/reactive/string_extensions.rb
volt-0.7.8 lib/volt/reactive/string_extensions.rb
volt-0.7.7 lib/volt/reactive/string_extensions.rb
volt-0.7.6 lib/volt/reactive/string_extensions.rb
volt-0.7.5 lib/volt/reactive/string_extensions.rb
volt-0.7.4 lib/volt/reactive/string_extensions.rb
volt-0.7.3 lib/volt/reactive/string_extensions.rb