Class: ActionView::OutputBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/kaizan.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOutputBuffer

Returns a new instance of OutputBuffer.



26
27
28
29
30
31
# File 'lib/kaizan.rb', line 26

def initialize(*)
  super

  self.altering_anchor = {}
  self.anonymous_anchor = []
end

Instance Attribute Details

#altering_anchorObject

Returns the value of attribute altering_anchor.



23
24
25
# File 'lib/kaizan.rb', line 23

def altering_anchor
  @altering_anchor
end

#anonymous_anchorObject

Returns the value of attribute anonymous_anchor.



23
24
25
# File 'lib/kaizan.rb', line 23

def anonymous_anchor
  @anonymous_anchor
end

Instance Method Details

#alter_past!(name, content) ⇒ Object



34
35
36
37
# File 'lib/kaizan.rb', line 34

def alter_past!(name, content)
  return unless (anchor = detect_anchor(name)).present?
  gsub_not_safety!(anchor, alter_string_safety(content))
end

#alter_string_safety(content) ⇒ Object



40
41
42
# File 'lib/kaizan.rb', line 40

def alter_string_safety(content)
  content.html_safe? ? content.to_s : html_escape_interpolated_argument_force(content.to_s)
end

#register_anchor(name = nil) ⇒ Object



45
46
47
48
49
50
# File 'lib/kaizan.rb', line 45

def register_anchor(name = nil)
  generate_anchor(name).tap { |anchor|
    anonymous_anchor.push(anchor)
    altering_anchor[name] = anchor if name.present?
  }.html_safe
end