Module: AsyncPartial::ArrayBuffer
- Defined in:
- lib/async_partial.rb
Instance Attribute Summary collapse
-
#buffer_values ⇒ Object
Returns the value of attribute buffer_values.
Instance Method Summary collapse
- #<<(value) ⇒ Object (also: #append=)
- #initialize ⇒ Object
- #safe_concat(value) ⇒ Object (also: #safe_append=)
- #safe_expr_append=(val) ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#buffer_values ⇒ Object
Returns the value of attribute buffer_values.
91 92 93 |
# File 'lib/async_partial.rb', line 91 def buffer_values @buffer_values end |
Instance Method Details
#<<(value) ⇒ Object Also known as: append=
98 99 100 101 |
# File 'lib/async_partial.rb', line 98 def <<(value) @buffer_values << [value, :<<] unless value.nil? self end |
#initialize ⇒ Object
93 94 95 96 |
# File 'lib/async_partial.rb', line 93 def initialize(*) super @buffer_values = [] end |
#safe_concat(value) ⇒ Object Also known as: safe_append=
104 105 106 107 108 |
# 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 |
#safe_expr_append=(val) ⇒ Object
111 112 113 114 |
# 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 ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# 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 |