Class: ViewModels::RenderOptions::Base
- Inherits:
-
Object
- Object
- ViewModels::RenderOptions::Base
- Defined in:
- lib/view_models/render_options.rb
Overview
Base class for Partial and Template.
Instance Attribute Summary (collapse)
-
- (Object) file
The different attributes used to generate render options.
-
- (Object) format
The different attributes used to generate render options.
-
- (Object) name
The different attributes used to generate render options.
-
- (Object) path
The different attributes used to generate render options.
-
- (Object) prefix
The different attributes used to generate render options.
-
- (Object) view_model
The different attributes used to generate render options.
Instance Method Summary (collapse)
-
- (String) error_format
The format when trying to render.
-
- (Object) error_message
Generate a suitable error message for the error options.
-
- (String) error_path
The error path, always returns a string.
- - (Object) format!(view)
-
- (Base) initialize(prefix, name, options)
constructor
Initialize Render Options.
-
- (Object) path_key
Used for caching.
-
- (Hash) to_render_options
Used when rendering.
Constructor Details
- (Base) initialize(prefix, name, options)
Initialize Render Options
20 21 22 23 24 25 |
# File 'lib/view_models/render_options.rb', line 20 def initialize prefix, name, @prefix = prefix @options = self.template_name = deoptionize name @format = @options.delete :format end |
Instance Attribute Details
- (Object) file
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def file @file end |
- (Object) format
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def format @format end |
- (Object) name
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def name @name end |
- (Object) path
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def path @path end |
- (Object) prefix
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def prefix @prefix end |
- (Object) view_model
The different attributes used to generate render options
13 14 15 |
# File 'lib/view_models/render_options.rb', line 13 def view_model @view_model end |
Instance Method Details
- (String) error_format
The format when trying to render
44 45 46 47 |
# File 'lib/view_models/render_options.rb', line 44 def error_format format = self.format format ? "format #{format}" : "default format" end |
- (Object) error_message
Generate a suitable error message for the error options.
29 30 31 |
# File 'lib/view_models/render_options.rb', line 29 def "'#{error_path}#{name}' with #{error_format}" end |
- (String) error_path
The error path, always returns a string
36 37 38 39 |
# File 'lib/view_models/render_options.rb', line 36 def error_path path = self.path path ? "#{path}/" : "" end |
- (Object) format!(view)
Rails specific.
61 62 63 |
# File 'lib/view_models/render_options.rb', line 61 def format! view view.template_format = @format if @format end |
- (Object) path_key
Used for caching.
67 68 69 |
# File 'lib/view_models/render_options.rb', line 67 def path_key [self.path, self.name, self.format] end |
- (Hash) to_render_options
Used when rendering.
52 53 54 55 56 |
# File 'lib/view_models/render_options.rb', line 52 def @options[:locals] ||= {} @options[:locals].reverse_merge! :view_model => view_model @options.reverse_merge :file => file end |