Class: ScriptFlow::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/script_flow/model/map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMap

Returns a new instance of Map.



7
8
9
# File 'lib/script_flow/model/map.rb', line 7

def initialize
  @content = ActiveSupport::OrderedHash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new }
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/script_flow/model/map.rb', line 3

def content
  @content
end

Instance Method Details

#add_script(script) ⇒ Object



27
28
29
# File 'lib/script_flow/model/map.rb', line 27

def add_script(script)
  set(script.hash, script)
end

#append(key, value) ⇒ Object Also known as: append!

Called by content_for



22
23
24
# File 'lib/script_flow/model/map.rb', line 22

def append(key, value)
  @content[key] << value
end

#get(key) ⇒ Object

Called by _layout_for to read stored values.



12
13
14
# File 'lib/script_flow/model/map.rb', line 12

def get(key)
  @content[key]
end

#renderObject



31
32
33
# File 'lib/script_flow/model/map.rb', line 31

def render
  @content.values.join("\n").html_safe
end

#set(key, value) ⇒ Object

Called by each renderer object to set the layout contents.



17
18
19
# File 'lib/script_flow/model/map.rb', line 17

def set(key, value)
  @content[key] = value
end