Class: Tzispa::Context

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tzispa/context.rb

Overview

This class defines a environment to hold application state in runtime

Direct Known Subclasses

Http::Context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Context

Returns a new instance of Context.



13
14
15
16
17
# File 'lib/tzispa/context.rb', line 13

def initialize(environment)
  @env = environment
  @repository = app.repository.dup if app.repository
  I18n.locale = config.locales.default.to_sym if config.respond_to?(:locales)
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



10
11
12
# File 'lib/tzispa/context.rb', line 10

def env
  @env
end

#repositoryObject (readonly)

Returns the value of attribute repository.



10
11
12
# File 'lib/tzispa/context.rb', line 10

def repository
  @repository
end

Instance Method Details

#appObject



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

def app
  @app ||= env[Tzispa::ENV_TZISPA_APP]
end