Class: CckForms::ParameterTypeClass::StringCollection
- Inherits:
-
Object
- Object
- CckForms::ParameterTypeClass::StringCollection
- Includes:
- Base
- Defined in:
- lib/cck_forms/parameter_type_class/string_collection.rb
Overview
Represents a collection of text strings (tags etc.)
Class Method Summary collapse
-
.demongoize_value(value, parameter_type_class = nil) ⇒ Object
Everything to array.
Instance Method Summary collapse
-
#build_form(form_builder, options) ⇒ Object
Builds a TEXTAREA, each string is a separate line.
-
#mongoize ⇒ Object
String: “aaarnxxx” -> [“aaa”, “xxx”] :each: -> array.
Class Method Details
.demongoize_value(value, parameter_type_class = nil) ⇒ Object
Everything to array
17 18 19 20 21 22 23 24 |
# File 'lib/cck_forms/parameter_type_class/string_collection.rb', line 17 def self.demongoize_value(value, parameter_type_class=nil) if value.is_a? String value = [value] elsif value.respond_to? :each value = value.to_a end super end |
Instance Method Details
#build_form(form_builder, options) ⇒ Object
Builds a TEXTAREA, each string is a separate line
27 28 29 30 31 32 |
# File 'lib/cck_forms/parameter_type_class/string_collection.rb', line 27 def build_form(form_builder, ) set_value_in_hash [:value] = value.join("\r\n") if value form_builder.text_area :value, {cols: 50, rows: 5, class: 'form-control'}.merge() end |
#mongoize ⇒ Object
String: “aaarnxxx” -> [“aaa”, “xxx”] :each: -> array
8 9 10 11 12 13 14 |
# File 'lib/cck_forms/parameter_type_class/string_collection.rb', line 8 def mongoize if value.is_a? String value.split "\r\n" elsif value.respond_to? :each value.to_a end end |