Class: Utopia::Content::Node::Context

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#documentObject

Returns the value of attribute document

Returns:

  • (Object)

    the current value of document



148
149
150
# File 'lib/utopia/content/node.rb', line 148

def document
  @document
end

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



148
149
150
# File 'lib/utopia/content/node.rb', line 148

def state
  @state
end

Instance Method Details

#[](key) ⇒ Object

Fetch an attribute from the current state or document defaults.



198
199
200
# File 'lib/utopia/content/node.rb', line 198

def [] key
	state.attributes.fetch(key){document.attributes[key]}
end

#attributesObject

Return attributes for the current rendering state.



191
192
193
# File 'lib/utopia/content/node.rb', line 191

def attributes
	state.attributes
end

#contentObject

Return the captured content of the current node.



206
207
208
# File 'lib/utopia/content/node.rb', line 206

def content
	document.content
end

#controllerObject

Return the controller associated with the document.



167
168
169
# File 'lib/utopia/content/node.rb', line 167

def controller
	document.controller
end

#firstObject

Return the first rendering state in the document.



218
219
220
# File 'lib/utopia/content/node.rb', line 218

def first
	document.first
end

Return or enumerate links relative to the current node.



227
228
229
# File 'lib/utopia/content/node.rb', line 227

def links(*arguments, **options, &block)
	state.node.links(*arguments, **options, &block)
end

#localizationObject

Return the document's localization preferences.



173
174
175
# File 'lib/utopia/content/node.rb', line 173

def localization
	document.localization
end

#parentObject

Return the enclosing rendering state.



212
213
214
# File 'lib/utopia/content/node.rb', line 212

def parent
	document.parent
end

#partial(*arguments, &block) ⇒ Object Also known as: deferred_tag

Render or defer a partial content block.



153
154
155
156
157
158
159
160
161
# File 'lib/utopia/content/node.rb', line 153

def partial(*arguments, &block)
	if block_given?
		state.defer(&block)
	else
		state.defer do |document|
			document.tag(*arguments)
		end
	end
end

#requestObject

Return the application request being rendered.



179
180
181
# File 'lib/utopia/content/node.rb', line 179

def request
	document.request
end

#responseObject

Return the document response being rendered.



185
186
187
# File 'lib/utopia/content/node.rb', line 185

def response
	document
end