Module: WorldScreens
- Defined in:
- lib/testcentricity_apps/world_extensions.rb
Instance Method Summary collapse
-
#instantiate_screen_objects ⇒ Object
instantiate and register all screen objects specified in screen_objects method.
Instance Method Details
#instantiate_screen_objects ⇒ Object
instantiate and register all screen objects specified in screen_objects method
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/testcentricity_apps/world_extensions.rb', line 34 def instantiate_screen_objects # return if screen objects have already been instantiated and registered return if TestCentricity::ScreenManager.loaded? # instantiate all screen objects @screens = {} screen_objects.each do |screen_object, screen_class| obj = screen_class.new @screens[screen_object] = obj unless @screens.has_key?(screen_object) screen_names = obj.screen_name screen_names = Array(screen_names) if screen_names.is_a? String screen_names.each do |name| screen_key = name.gsub(/\s+/, '').downcase.to_sym @screens[screen_key] = obj unless @screens.has_key?(screen_key) end # define screen object accessor method define_method(screen_object) do if instance_variable_defined?(:"@#{screen_object}") instance_variable_get(:"@#{screen_object}") else instance_variable_set(:"@#{screen_object}", TestCentricity::ScreenManager.find_screen(screen_object)) end end end # register all screen objects with ScreenManager TestCentricity::ScreenManager.register_screen_objects(@screens) end |