Module: Metro::SceneView

Included in:
Scene
Defined in:
lib/metro/views/scene_view.rb

Overview

SceneView provides support for a Scene to have a view as well as giving additional tools to also help draw that view.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

When the module is included insure that all the class helper methods are added at the same time.



67
68
69
# File 'lib/metro/views/scene_view.rb', line 67

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#save_viewObject

Saves the current content of the view back through the view’s writer



58
59
60
61
# File 'lib/metro/views/scene_view.rb', line 58

def save_view
  view.content = self.to_hash
  view.save
end

#viewObject

Returns the view for this scene.

Returns:

  • the view for this scene.



41
42
43
# File 'lib/metro/views/scene_view.rb', line 41

def view
  self.class.view
end

#view_contentObject

Loads and caches the view content based on the avilable view parsers and the view files defined.

Returns:

  • the content contained within the view



51
52
53
# File 'lib/metro/views/scene_view.rb', line 51

def view_content
  view.content
end

#view_nameObject

A Scene by default uses the name of the Scene to find it’s associated view.

Examples:

Standard View Name


class OpeningScene < Metro::Scene

  def show
    puts "View Brought To You By: #{view_name} # => View Brought To You By opening
  end
end

Custom View Name


class ClosingScene < Metro::Scene
  view_name 'alternative'

  def show
    puts "View Brought To You By: #{view_name} # => View Brought To You By alternative
  end
end


34
35
36
# File 'lib/metro/views/scene_view.rb', line 34

def view_name
  self.class.view_name
end