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



130
131
132
# File 'lib/utopia/content/node.rb', line 130

def document
  @document
end

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



130
131
132
# File 'lib/utopia/content/node.rb', line 130

def state
  @state
end

Instance Method Details

#[](key) ⇒ Object



163
164
165
# File 'lib/utopia/content/node.rb', line 163

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

#attributesObject



159
160
161
# File 'lib/utopia/content/node.rb', line 159

def attributes
	state.attributes
end

#contentObject



169
170
171
# File 'lib/utopia/content/node.rb', line 169

def content
	document.content
end

#controllerObject



143
144
145
# File 'lib/utopia/content/node.rb', line 143

def controller
	document.controller
end

#firstObject



177
178
179
# File 'lib/utopia/content/node.rb', line 177

def first
	document.first
end


181
182
183
# File 'lib/utopia/content/node.rb', line 181

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

#localizationObject



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

def localization
	document.localization
end

#parentObject



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

def parent
	document.parent
end

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



131
132
133
134
135
136
137
138
139
# File 'lib/utopia/content/node.rb', line 131

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

#requestObject



151
152
153
# File 'lib/utopia/content/node.rb', line 151

def request
	document.request
end

#responseObject



155
156
157
# File 'lib/utopia/content/node.rb', line 155

def response
	document
end