Class: Utopia::Content::Node::Context
- Inherits:
-
Struct
- Object
- Struct
- Utopia::Content::Node::Context
- Defined in:
- lib/utopia/content/node.rb
Overview
This is a special context in which a limited set of well defined methods are exposed in the content view.
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
-
#state ⇒ Object
(also: #current)
Returns the value of attribute state.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #attributes ⇒ Object
- #content ⇒ Object
- #controller ⇒ Object
- #first ⇒ Object
- #links(*arguments, **options, &block) ⇒ Object
- #localization ⇒ Object
- #parent ⇒ Object
- #partial(*arguments, &block) ⇒ Object (also: #deferred_tag)
- #request ⇒ Object
- #response ⇒ Object
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document
114 115 116 |
# File 'lib/utopia/content/node.rb', line 114 def document @document end |
#state ⇒ Object Also known as: current
Returns the value of attribute state
114 115 116 |
# File 'lib/utopia/content/node.rb', line 114 def state @state end |
Instance Method Details
#[](key) ⇒ Object
147 148 149 |
# File 'lib/utopia/content/node.rb', line 147 def [] key state.attributes.fetch(key) {document.attributes[key]} end |
#attributes ⇒ Object
143 144 145 |
# File 'lib/utopia/content/node.rb', line 143 def attributes state.attributes end |
#content ⇒ Object
153 154 155 |
# File 'lib/utopia/content/node.rb', line 153 def content document.content end |
#controller ⇒ Object
127 128 129 |
# File 'lib/utopia/content/node.rb', line 127 def controller document.controller end |
#first ⇒ Object
161 162 163 |
# File 'lib/utopia/content/node.rb', line 161 def first document.first end |
#links(*arguments, **options, &block) ⇒ Object
165 166 167 |
# File 'lib/utopia/content/node.rb', line 165 def links(*arguments, **, &block) state.node.links(*arguments, **, &block) end |
#localization ⇒ Object
131 132 133 |
# File 'lib/utopia/content/node.rb', line 131 def localization document.localization end |
#parent ⇒ Object
157 158 159 |
# File 'lib/utopia/content/node.rb', line 157 def parent document.parent end |
#partial(*arguments, &block) ⇒ Object Also known as: deferred_tag
115 116 117 118 119 120 121 122 123 |
# File 'lib/utopia/content/node.rb', line 115 def partial(*arguments, &block) if block_given? state.defer(&block) else state.defer do |document| document.tag(*arguments) end end end |
#request ⇒ Object
135 136 137 |
# File 'lib/utopia/content/node.rb', line 135 def request document.request end |
#response ⇒ Object
139 140 141 |
# File 'lib/utopia/content/node.rb', line 139 def response document end |