Class: StoryTeller::Application

Inherits:
Object
  • #Object
show all
Defined in:
lib/story_teller/application.rb

Overview

The Application class is the host composition root for a StoryTeller runtime.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = StoryTeller::Config.defaults) ⇒ Application

Returns a new instance of Application.



28
29
30
31
32
33
# File 'lib/story_teller/application.rb', line 28

def initialize(options = StoryTeller::Config.defaults)
  @options = options
  configure_engine
  configure_context
  @runtime = StoryTeller::Runtime.instance(@options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



26
27
28
# File 'lib/story_teller/application.rb', line 26

def options
  @options
end

#runtimeObject (readonly)

Returns the value of attribute runtime.



26
27
28
# File 'lib/story_teller/application.rb', line 26

def runtime
  @runtime
end

Instance Method Details

#load_gameObject



35
36
37
38
# File 'lib/story_teller/application.rb', line 35

def load_game
  runtime.persistence.reset! if options[:reset_db_each_session]
  runtime.load_game
end

#play_gameObject



40
41
42
43
# File 'lib/story_teller/application.rb', line 40

def play_game
  runtime.manage_privileges
  runtime.play_game
end

#runObject



45
46
47
48
# File 'lib/story_teller/application.rb', line 45

def run
  load_game
  play_game
end