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



136
137
138
# File 'lib/utopia/content/node.rb', line 136

def document
  @document
end

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • (Object)

    the current value of 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

#attributesObject



165
166
167
# File 'lib/utopia/content/node.rb', line 165

def attributes
	state.attributes
end

#contentObject



175
176
177
# File 'lib/utopia/content/node.rb', line 175

def content
	document.content
end

#controllerObject



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

def controller
	document.controller
end

#firstObject



183
184
185
# File 'lib/utopia/content/node.rb', line 183

def first
	document.first
end


187
188
189
# File 'lib/utopia/content/node.rb', line 187

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

#localizationObject



153
154
155
# File 'lib/utopia/content/node.rb', line 153

def localization
	document.localization
end

#parentObject



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

#requestObject



157
158
159
# File 'lib/utopia/content/node.rb', line 157

def request
	document.request
end

#responseObject



161
162
163
# File 'lib/utopia/content/node.rb', line 161

def response
	document
end