Class: Cosmo::Web::Context

Inherits:
Object
  • Object
show all
Includes:
Helpers::Application
Defined in:
lib/cosmo/web/context.rb

Constant Summary

Constants included from Renderer

Renderer::ASSETS_ROOT, Renderer::VIEWS_ROOT

Instance Method Summary collapse

Methods included from Helpers::Application

#current_page?, #elapsed, #format_bytes, #format_numbers, #format_timestamp, #h, #referrer?, #time_until, #u

Methods included from Renderer

#no_content, #not_found, #ok, #redirect_to, #serve, #url_for

Constructor Details

#initialize(locals, content_for = nil) ⇒ Context

Returns a new instance of Context.



10
11
12
13
# File 'lib/cosmo/web/context.rb', line 10

def initialize(locals, content_for = nil)
  @content_for = Hash(content_for)
  locals.each { |k, v| instance_variable_set("@#{k}", v) }
end

Instance Method Details

#bindingObject

rubocop:disable Lint/UselessMethodDefinition



15
16
17
# File 'lib/cosmo/web/context.rb', line 15

def binding # rubocop:disable Lint/UselessMethodDefinition
  super
end

#content_for(name) ⇒ Object



19
20
21
# File 'lib/cosmo/web/context.rb', line 19

def content_for(name)
  @content_for[name]
end

#content_for?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cosmo/web/context.rb', line 23

def content_for?(name)
  @content_for.key?(name)
end