Class: CckForms::ParameterTypeClass::StringCollection

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, 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

#mongoizeObject

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