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

#stateObject Also known as: current

Returns the value of attribute state

Returns:

  • the current value of state



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

def state
  @state
end

#transactionObject

Returns the value of attribute transaction

Returns:

  • the current value of transaction



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

def transaction
  @transaction
end

Instance Method Details

#[](key) ⇒ Object



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

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

#attributesObject



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

def attributes
  state.attributes
end

#contentObject



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

def content
  transaction.content
end

#controllerObject



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

def controller
  transaction.controller
end

#firstObject



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

def first
  transaction.first
end


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

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

#localizationObject



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

def localization
  transaction.localization
end

#parentObject



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

def parent
  transaction.parent
end

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



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

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

#requestObject



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

def request
  transaction.request
end

#responseObject



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

def response
  transaction
end