class CckForms::ParameterTypeClass::StringCollection

Represents a collection of text strings (tags etc.)

Public Class Methods

demongoize_value(value, parameter_type_class=nil) click to toggle source

Everything to array

# 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

Public Instance Methods

build_form(form_builder, options) click to toggle source

Builds a TEXTAREA, each string is a separate line

# File lib/cck_forms/parameter_type_class/string_collection.rb, line 27
def build_form(form_builder, options)
  set_value_in_hash options
  options[:value] = value.join("\r\n") if value

  form_builder.text_area :value, {cols: 50, rows: 5, class: 'form-control'}.merge(options)
end
mongoize() click to toggle source

String: “aaarnxxx” -> [“aaa”, “xxx”] :each: -> array

# 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