Class: Metro::Views::JSONView
- Inherits:
-
Object
- Object
- Metro::Views::JSONView
- Defined in:
- lib/metro/views/json_view.rb
Overview
Provides support for a JSON Representation of a view.
Class Method Summary collapse
-
.exists?(view_path) ⇒ Boolean
Determine if a view exists for this specified format.
-
.format ⇒ Object
The file type format of this view.
-
.parse(view_path) ⇒ Object
Parse the contents of the view given the name.
-
.write(view_path, content) ⇒ Object
Writes the content out to the spcified view path.
Class Method Details
.exists?(view_path) ⇒ Boolean
Determine if a view exists for this specified format
17 18 19 |
# File 'lib/metro/views/json_view.rb', line 17 def self.exists?(view_path) File.exists? json_view_path(view_path) end |
.format ⇒ Object
Returns the file type format of this view.
34 35 36 |
# File 'lib/metro/views/json_view.rb', line 34 def self.format :json end |
.parse(view_path) ⇒ Object
Parse the contents of the view given the name.
27 28 29 |
# File 'lib/metro/views/json_view.rb', line 27 def self.parse(view_path) JSON.parse File.read json_view_path(view_path) end |
.write(view_path, content) ⇒ Object
Writes the content out to the spcified view path
41 42 43 44 45 |
# File 'lib/metro/views/json_view.rb', line 41 def self.write(view_path,content) filename = json_view_path(view_path) json_content = JSON.pretty_generate(content) File.write(filename,json_content) end |