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



114
115
116
# File 'lib/utopia/content/node.rb', line 114

def document
  @document
end

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



114
115
116
# File 'lib/utopia/content/node.rb', line 114

def state
  @state
end

Instance Method Details

#[](key) ⇒ Object



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

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

#attributesObject



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

def attributes
	state.attributes
end

#contentObject



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

def content
	document.content
end

#controllerObject



127
128
129
# File 'lib/utopia/content/node.rb', line 127

def controller
	document.controller
end

#firstObject



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

def first
	document.first
end


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

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

#localizationObject



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

def localization
	document.localization
end

#parentObject



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

def parent
	document.parent
end

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



115
116
117
118
119
120
121
122
123
# File 'lib/utopia/content/node.rb', line 115

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

#requestObject



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

def request
	document.request
end

#responseObject



139
140
141
# File 'lib/utopia/content/node.rb', line 139

def response
	document
end