Class: ScriptFlow::Map
- Inherits:
-
Object
- Object
- ScriptFlow::Map
- Defined in:
- lib/script_flow/model/map.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Instance Method Summary collapse
- #add_script(script) ⇒ Object
-
#append(key, value) ⇒ Object
(also: #append!)
Called by content_for.
-
#get(key) ⇒ Object
Called by _layout_for to read stored values.
-
#initialize ⇒ Map
constructor
A new instance of Map.
- #render ⇒ Object
-
#set(key, value) ⇒ Object
Called by each renderer object to set the layout contents.
Constructor Details
#initialize ⇒ Map
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
#content ⇒ Object (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 |
#render ⇒ Object
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 |