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

#document ⇒ Object

Returns the value of attribute document

Returns:

  • (Object) —

    the current value of document



133
134
135
# File 'lib/utopia/content/node.rb', line 133

def document
  @document
end

#state ⇒ Object Also known as: current

Returns the value of attribute state

Returns:

  • (Object) —

    the current value of state



133
134
135
# File 'lib/utopia/content/node.rb', line 133

def state
  @state
end

Instance Method Details

#[](key) ⇒ Object



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

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

#attributes ⇒ Object



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

def attributes
	state.attributes
end

#content ⇒ Object



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

def content
	document.content
end

#controller ⇒ Object



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

def controller
	document.controller
end

#first ⇒ Object



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

def first
	document.first
end


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

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

#localization ⇒ Object



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

def localization
	document.localization
end

#parent ⇒ Object



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

def parent
	document.parent
end

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



134
135
136
137
138
139
140
141
142
# File 'lib/utopia/content/node.rb', line 134

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

#request ⇒ Object



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

def request
	document.request
end

#response ⇒ Object



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

def response
	document
end