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(*args, &block) ⇒ Object (also: #deferred_tag)
- #request ⇒ Object
- #response ⇒ Object
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document
136 137 138 |
# File 'lib/utopia/content/node.rb', line 136 def document @document end |
#state ⇒ Object Also known as: current
Returns the value of attribute state
136 137 138 |
# File 'lib/utopia/content/node.rb', line 136 def state @state end |
Instance Method Details
#[](key) ⇒ Object
169 170 171 |
# File 'lib/utopia/content/node.rb', line 169 def [] key state.attributes.fetch(key) {document.attributes[key]} end |
#attributes ⇒ Object
165 166 167 |
# File 'lib/utopia/content/node.rb', line 165 def attributes state.attributes end |
#content ⇒ Object
175 176 177 |
# File 'lib/utopia/content/node.rb', line 175 def content document.content end |
#controller ⇒ Object
149 150 151 |
# File 'lib/utopia/content/node.rb', line 149 def controller document.controller end |
#first ⇒ Object
183 184 185 |
# File 'lib/utopia/content/node.rb', line 183 def first document.first end |
#links(*arguments, **options, &block) ⇒ Object
187 188 189 |
# File 'lib/utopia/content/node.rb', line 187 def links(*arguments, **, &block) state.node.links(*arguments, **, &block) end |
#localization ⇒ Object
153 154 155 |
# File 'lib/utopia/content/node.rb', line 153 def localization document.localization end |
#parent ⇒ Object
179 180 181 |
# File 'lib/utopia/content/node.rb', line 179 def parent document.parent end |
#partial(*args, &block) ⇒ Object Also known as: deferred_tag
137 138 139 140 141 142 143 144 145 |
# File 'lib/utopia/content/node.rb', line 137 def partial(*args, &block) if block_given? state.defer(&block) else state.defer do |document| document.tag(*args) end end end |
#request ⇒ Object
157 158 159 |
# File 'lib/utopia/content/node.rb', line 157 def request document.request end |
#response ⇒ Object
161 162 163 |
# File 'lib/utopia/content/node.rb', line 161 def response document end |