Class: Phlex::Context Private
- Inherits:
-
Object
- Object
- Phlex::Context
- Defined in:
- lib/phlex/context.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #buffer ⇒ Object private
- #capturing ⇒ Object private
- #fragments ⇒ Object readonly private
- #in_target_fragment ⇒ Object private
- #user_context ⇒ Object private
Instance Method Summary collapse
- #around_render ⇒ Object private
- #begin_target(id) ⇒ Object private
- #capturing_into(new_buffer) ⇒ Object private
- #end_target ⇒ Object private
-
#initialize(user_context = {}) ⇒ Context
constructor
private
A new instance of Context.
-
#target ⇒ Object
private
Added for backwards compatibility with phlex-rails.
- #target_fragments(fragments) ⇒ Object private
Constructor Details
#initialize(user_context = {}) ⇒ Context
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Context.
5 6 7 8 9 10 11 12 |
# File 'lib/phlex/context.rb', line 5 def initialize(user_context = {}) @buffer = +"" @capturing = false @user_context = user_context @fragments = nil @in_target_fragment = false @halt_signal = nil end |
Instance Attribute Details
#buffer ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/phlex/context.rb', line 14 def buffer @buffer end |
#capturing ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/phlex/context.rb', line 14 def capturing @capturing end |
#fragments ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 |
# File 'lib/phlex/context.rb', line 16 def fragments @fragments end |
#in_target_fragment ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/phlex/context.rb', line 14 def in_target_fragment @in_target_fragment end |
#user_context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/phlex/context.rb', line 14 def user_context @user_context end |
Instance Method Details
#around_render ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 31 32 33 34 |
# File 'lib/phlex/context.rb', line 27 def around_render return yield if !@fragments || @halt_signal catch do |signal| @halt_signal = signal yield end end |
#begin_target(id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 |
# File 'lib/phlex/context.rb', line 36 def begin_target(id) @in_target_fragment = id end |
#capturing_into(new_buffer) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/phlex/context.rb', line 46 def capturing_into(new_buffer) original_buffer = @buffer original_capturing = @capturing original_fragments = @fragments begin @buffer = new_buffer @capturing = true @fragments = nil yield ensure @buffer = original_buffer @capturing = original_capturing @fragments = original_fragments end new_buffer end |
#end_target ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 |
# File 'lib/phlex/context.rb', line 40 def end_target @fragments.delete(@in_target_fragment) @in_target_fragment = false throw @halt_signal if @fragments.length == 0 end |
#target ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Added for backwards compatibility with phlex-rails. We can remove this with 2.0
19 20 21 |
# File 'lib/phlex/context.rb', line 19 def target @buffer end |
#target_fragments(fragments) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/phlex/context.rb', line 23 def target_fragments(fragments) @fragments = fragments.to_h { |it| [it, true] } end |