Class: RubyApp::Response

Inherits:
Rack::Response
  • Object
show all
Extended by:
Mixins::DelegateMixin
Defined in:
lib/ruby_app/response.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::DelegateMixin

method_missing

Class Method Details

.create!Object



39
40
41
# File 'lib/ruby_app/response.rb', line 39

def self.create!
  Thread.current[:_response] = RubyApp::Response.new
end

.destroy!Object



43
44
45
# File 'lib/ruby_app/response.rb', line 43

def self.destroy!
  Thread.current[:_response] = nil
end

.getObject



35
36
37
# File 'lib/ruby_app/response.rb', line 35

def self.get
  return Thread.current[:_response]
end

Instance Method Details

#clear_content(element) ⇒ Object



31
32
33
# File 'lib/ruby_app/response.rb', line 31

def clear_content(element)
  @content[element] = {}
end

#content_for(element, name, value = nil, &block) ⇒ Object



21
22
23
24
# File 'lib/ruby_app/response.rb', line 21

def content_for(element, name, value = nil, &block)
  @content[element] ||= {}
  @content[element][name] = block_given? ? block : String.interpolate { value }
end

#get_content(element, name) ⇒ Object



26
27
28
29
# File 'lib/ruby_app/response.rb', line 26

def get_content(element, name)
  @content[element] ||= {}
  return @content[element][name]
end

#rendered(template) ⇒ Object



17
18
19
# File 'lib/ruby_app/response.rb', line 17

def rendered(template)
  @rendered[template] = true
end

#rendered?(template) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ruby_app/response.rb', line 13

def rendered?(template)
  return @rendered.key?(template)
end