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
134 135 136 |
# File 'lib/utopia/content/node.rb', line 134 def document @document end |
#state ⇒ Object Also known as: current
Returns the value of attribute state
134 135 136 |
# File 'lib/utopia/content/node.rb', line 134 def state @state end |
Instance Method Details
#[](key) ⇒ Object
167 168 169 |
# File 'lib/utopia/content/node.rb', line 167 def [] key state.attributes.fetch(key) {document.attributes[key]} end |
#attributes ⇒ Object
163 164 165 |
# File 'lib/utopia/content/node.rb', line 163 def attributes state.attributes end |
#content ⇒ Object
173 174 175 |
# File 'lib/utopia/content/node.rb', line 173 def content document.content end |
#controller ⇒ Object
147 148 149 |
# File 'lib/utopia/content/node.rb', line 147 def controller document.controller end |
#first ⇒ Object
181 182 183 |
# File 'lib/utopia/content/node.rb', line 181 def first document.first end |
#links(*arguments, **options, &block) ⇒ Object
185 186 187 |
# File 'lib/utopia/content/node.rb', line 185 def links(*arguments, **, &block) state.node.links(*arguments, **, &block) end |
#localization ⇒ Object
151 152 153 |
# File 'lib/utopia/content/node.rb', line 151 def localization document.localization end |
#parent ⇒ Object
177 178 179 |
# File 'lib/utopia/content/node.rb', line 177 def parent document.parent end |
#partial(*args, &block) ⇒ Object Also known as: deferred_tag
135 136 137 138 139 140 141 142 143 |
# File 'lib/utopia/content/node.rb', line 135 def partial(*args, &block) if block_given? state.defer(&block) else state.defer do |document| document.tag(*args) end end end |
#request ⇒ Object
155 156 157 |
# File 'lib/utopia/content/node.rb', line 155 def request document.request end |
#response ⇒ Object
159 160 161 |
# File 'lib/utopia/content/node.rb', line 159 def response document end |