Class: View::Array Abstract
Overview
This class is abstract.
Subclass this for html safe lists with formatted each support.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary (collapse)
- - (Boolean) all_safe?
- - (Object) each_options
- - (Object) formatted_values
-
- (Object) to_s
The formatted value will be html safe if all the elements in the array are safe too.
Methods inherited from Formatter
#all_options, as, #format, #format!, inherited, #options, skip_blank_formatter, type
Instance Method Details
- (Boolean) all_safe?
17 18 19 20 21 |
# File 'lib/view/formatters/array.rb', line 17 def all_safe? formatted_values.all? do |element| element.respond_to?(:html_safe?) && element.html_safe? end end |
- (Object) each_options
29 30 31 |
# File 'lib/view/formatters/array.rb', line 29 def [:each] || { :as => View.configuration.default_formatter } end |
- (Object) formatted_values
23 24 25 26 27 |
# File 'lib/view/formatters/array.rb', line 23 def formatted_values @formatted_values ||= value.map do |element| View.format(element, , template, &block) end end |
- (Object) to_s
The formatted value will be html safe if all the elements in the array are safe too.
8 9 10 11 12 13 14 15 |
# File 'lib/view/formatters/array.rb', line 8 def to_s result = super if result.respond_to?(:html_safe) && all_safe? result.html_safe else result end end |