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.6.5 lib/volt/reactive/string_extensions.rb
volt-0.6.4 lib/volt/reactive/string_extensions.rb
volt-0.6.3 lib/volt/reactive/string_extensions.rb
volt-0.6.2 lib/volt/reactive/string_extensions.rb
volt-0.6.1 lib/volt/reactive/string_extensions.rb
volt-0.6.0 lib/volt/reactive/string_extensions.rb
volt-0.5.18 lib/volt/reactive/string_extensions.rb
volt-0.5.17 lib/volt/reactive/string_extensions.rb
volt-0.5.16 lib/volt/reactive/string_extensions.rb
volt-0.5.15 lib/volt/reactive/string_extensions.rb
volt-0.5.14 lib/volt/reactive/string_extensions.rb
volt-0.5.13 lib/volt/reactive/string_extensions.rb
volt-0.5.12 lib/volt/reactive/string_extensions.rb
volt-0.5.11 lib/volt/reactive/string_extensions.rb
volt-0.5.10 lib/volt/reactive/string_extensions.rb
volt-0.5.9 lib/volt/reactive/string_extensions.rb
volt-0.5.8 lib/volt/reactive/string_extensions.rb
volt-0.5.7 lib/volt/reactive/string_extensions.rb
volt-0.5.6 lib/volt/reactive/string_extensions.rb
volt-0.5.4 lib/volt/reactive/string_extensions.rb