module AsyncPartial::ArrayBuffer

Attributes

buffer_values[RW]

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/async_partial.rb, line 93
def initialize(*)
  super
  @buffer_values = []
end

Public Instance Methods

<<(value) click to toggle source
# File lib/async_partial.rb, line 98
def <<(value)
  @buffer_values << [value, :<<] unless value.nil?
  self
end
Also aliased as: append=
append=(value)
Alias for: <<
safe_append=(value)
Alias for: safe_concat
safe_concat(value) click to toggle source
# File lib/async_partial.rb, line 104
def safe_concat(value)
  raise ActiveSupport::SafeBuffer::SafeConcatError unless html_safe?
  @buffer_values << [value, :safe_concat] unless value.nil?
  self
end
Also aliased as: safe_append=
safe_expr_append=(val) click to toggle source
# File lib/async_partial.rb, line 111
def safe_expr_append=(val)
  @buffer_values << [val, :safe_expr_append] unless val.nil?
  self
end
to_s() click to toggle source
# File lib/async_partial.rb, line 116
def to_s
  result = @buffer_values.each_with_object(ActiveSupport::SafeBuffer.new) do |(v, meth), buf|
    if meth == :<<
      if AsyncPartial::AsyncResult === v
        buf << v.value
      else
        buf << v.to_s
      end
    else
      if AsyncPartial::AsyncResult === v
        buf.safe_concat(v.value)
      else
        buf.safe_concat(v.to_s)
      end
    end
  end
  result.to_s
end