Sha256: d631ca767b28150894f614d64c6a53ee07e311002d95a286e332fb38d28964a4

Contents?: true

Size: 725 Bytes

Versions: 42

Compression:

Stored size: 725 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

42 entries across 42 versions & 1 rubygems

Version Path
volt-0.5.3 lib/volt/reactive/string_extensions.rb
volt-0.5.2 lib/volt/reactive/string_extensions.rb
volt-0.5.1 lib/volt/reactive/string_extensions.rb
volt-0.5.0 lib/volt/reactive/string_extensions.rb
volt-0.4.18 lib/volt/reactive/string_extensions.rb
volt-0.4.17 lib/volt/reactive/string_extensions.rb
volt-0.4.15 lib/volt/reactive/string_extensions.rb
volt-0.4.14 lib/volt/reactive/string_extensions.rb
volt-0.4.12 lib/volt/reactive/string_extensions.rb
volt-0.4.11 lib/volt/reactive/string_extensions.rb
volt-0.4.10 lib/volt/reactive/string_extensions.rb
volt-0.4.9 lib/volt/reactive/string_extensions.rb
volt-0.4.8 lib/volt/reactive/string_extensions.rb
volt-0.4.7 lib/volt/reactive/string_extensions.rb
volt-0.4.5 lib/volt/reactive/string_extensions.rb
volt-0.4.4 lib/volt/reactive/string_extensions.rb
volt-0.4.3 lib/volt/reactive/string_extensions.rb
volt-0.4.2 lib/volt/reactive/string_extensions.rb
volt-0.4.1 lib/volt/reactive/string_extensions.rb
volt-0.4.0 lib/volt/reactive/string_extensions.rb