Renamed helpers to correspond to renamed Controller classes.
[merb_radiant.git] / radiant_extensions_plugins / plugins / scenarios / lib / scenarios / .svn / text-base / loading.rb.svn-base
blobb369196e13077705a0a8ce14811ac8869ebe2781
1 module Scenarios
2   # Provides scenario loading and convenience methods around the Configuration
3   # that must be made available through a method _table_config_.
4   module Loading # :nodoc:
5     def load_scenarios(scenario_classes)
6       install_active_record_tracking_hook
7       scenario_classes.each do |scenario_class|
8         scenario = scenario_class.new(table_config)
9         scenario.load
10         table_config.loaded_scenarios << scenario
11       end if scenario_classes
12     end
13     
14     def loaded_scenarios
15       table_config.loaded_scenarios
16     end
17     
18     def scenarios_loaded?
19       table_config && table_config.scenarios_loaded?
20     end
21     
22     # The sum of all the loaded scenario's helper methods. These can be mixed
23     # into anything you like to gain access to them.
24     def scenario_helpers
25       table_config.scenario_helpers
26     end
27     
28     # The sum of all the available table reading methods. These will only
29     # include readers for which data has been placed into the table. These can
30     # be mixed into anything you like to gain access to them.
31     def table_readers
32       table_config.table_readers
33     end
34     
35     # # This understand nesting descriptions one deep
36     # def table_config
37     #   on_my_class = self.class.instance_variable_get("@table_config")
38     #   return on_my_class if on_my_class
39     #   
40     #   if self.class.superclass
41     #     on_super_class = self.class.superclass.instance_variable_get("@table_config")
42     #     return on_super_class if on_super_class
43     #   end
44     # end
45     
46     private
47       def install_active_record_tracking_hook
48         ActiveRecord::Base.table_config = table_config
49       end
50   end
51 end