Class: Cuboid::State
- Defined in:
- lib/cuboid/state.rb,
 lib/cuboid/state/options.rb,
 lib/cuboid/state/application.rb
Overview
Stores and provides access to the state of the system.
Defined Under Namespace
Classes: Application, Error, Options
Class Attribute Summary collapse
Class Method Summary collapse
- 
  
    
      .clear  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Clears all states. 
- 
  
    
      .dump(directory)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Location of the directory. 
- 
  
    
      .load(directory)  ⇒ State 
    
    
  
  
  
  
  
  
  
  
  
    ‘self`. 
- .reset ⇒ Object
- .statistics ⇒ Object
Class Attribute Details
.application ⇒ Framework
| 25 26 27 | # File 'lib/cuboid/state.rb', line 25 def application @application end | 
Class Method Details
.clear ⇒ Object
Clears all states.
| 69 70 71 72 | # File 'lib/cuboid/state.rb', line 69 def clear each { |_, state| state.clear } self end | 
.dump(directory) ⇒ String
Returns Location of the directory.
| 45 46 47 48 49 50 51 52 53 | # File 'lib/cuboid/state.rb', line 45 def dump( directory ) FileUtils.mkdir_p( directory ) each do |name, state| state.dump( "#{directory}/#{name}/" ) end directory end | 
.load(directory) ⇒ State
Returns ‘self`.
| 60 61 62 63 64 65 66 | # File 'lib/cuboid/state.rb', line 60 def load( directory ) each do |name, state| send( "#{name}=", state.class.load( "#{directory}/#{name}/" ) ) end self end | 
.reset ⇒ Object
| 27 28 29 30 | # File 'lib/cuboid/state.rb', line 27 def reset @options = Options.new @application = Application.new end | 
.statistics ⇒ Object
| 32 33 34 35 36 37 38 | # File 'lib/cuboid/state.rb', line 32 def statistics stats = {} each do |attribute| stats[attribute] = send(attribute).statistics end stats end |