Class: CustomFielder::Field
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- CustomFielder::Field
- Includes:
- DeserializationHelper, TypeCheckingHelper
- Defined in:
- app/models/custom_fielder/field.rb
Constant Summary collapse
- FIELD_TYPE_MAP =
{ 'Text' => 'String', 'Integer' => 'Fixnum', 'Decmial' => 'Float', 'Date' => 'Date', 'Date & Time' => 'DateTime', 'True/False' => 'Boolean', 'List' => 'Array' }
- FORM_FIELD_TYPES =
{ 'Text - Entry' => :text_entry_fields, 'Text - Multiple Choice' => :text_choice_fields, 'Integer - Entry' => :int_entry_fields, 'Integer - Multiple Choice' => :int_choice_fields, 'Decimal - Entry' => :float_entry_fields, 'Decimal - Multiple Choice' => :float_choice_fields, 'Date - Entry' => :date_entry_fields, 'Date - Multiple Choice' => :date_choice_fields, 'Date & Time - Entry' => :datetime_entry_fields, 'Date & Time - Multiple Choice' => :datetime_choice_fields, 'True/False' => :boolean_fields }
Constants included from DeserializationHelper
DeserializationHelper::FALSE_VALUES
Constants included from TypeCheckingHelper
TypeCheckingHelper::FALSE_VALUES, TypeCheckingHelper::TRUTH_VALUES
Class Method Summary collapse
-
.all_fields_hashed_for_opt_group ⇒ Hash
Creates a hash of form field types mapped to array of field, field id pairs meant for use in a form select dropdown with options group.
Instance Method Summary collapse
-
#options ⇒ Array
Returns the deserialized version of field_options.
Methods included from DeserializationHelper
#array, #boolean, #date, #date_time, #deserialize, #fixnum, #float, #string
Methods included from TypeCheckingHelper
#is_array?, #is_boolean?, #is_correct_type?, #is_date?, #is_date_time?, #is_fixnum?, #is_float?, #is_string?
Class Method Details
.all_fields_hashed_for_opt_group ⇒ Hash
Creates a hash of form field types mapped to array of field, field id pairs meant for use in a form select dropdown with options group
66 67 68 69 70 71 72 |
# File 'app/models/custom_fielder/field.rb', line 66 def self.all_fields_hashed_for_opt_group FORM_FIELD_TYPES.inject(Hash.new) do |hash, form_field| fields = send(form_field.last) hash[form_field.first] = fields.map { |field| [field.name, field.id] } unless fields.empty? hash end end |
Instance Method Details
#options ⇒ Array
Returns the deserialized version of field_options
79 80 81 |
# File 'app/models/custom_fielder/field.rb', line 79 def .nil? ? nil : deserialize('Array', ) end |