Class: Field

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/field.rb

Constant Summary collapse

@@field_config =
{
  'hidden' => [],
  'read_only' => [],
  'text_field' => [],
  'email_field' => [],
  'number_field' => [],
  'date_field' => ['format'],
  'text_area' => [],
  'boolean' => [],
  'enum' => ['enum_values'],
  'paperclip_field' => [],
  'belongs_to' => ['target_display_column'],
  'has_many' => ['target_model', 'target_section_id']
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.field_typesObject

returns array of possible field types



36
37
38
# File 'app/models/field.rb', line 36

def self.field_types
  @@field_config.keys
end

.valid_optionsObject



44
45
46
47
48
49
50
# File 'app/models/field.rb', line 44

def self.valid_options
  options = []
  @@field_config.each_value do |val|
    options.concat(val)
  end
  return options
end

Instance Method Details

#option_fieldsObject



40
41
42
# File 'app/models/field.rb', line 40

def option_fields
  self.field_type.blank? || !@@field_config.has_key?(self.field_type) ? [] : @@field_config[self.field_type] 
end


53
54
55
56
57
# File 'app/models/field.rb', line 53

def overview_link
  return false if self.options.blank?
  is_link = self.options[:overview_link]
  object_to_boolean(is_link)
end

#overview_link=(is_link) ⇒ Object



59
60
61
62
# File 'app/models/field.rb', line 59

def overview_link=(is_link)
  self.options = Hash.new if self.options.blank?
  self.options[:overview_link] = object_to_boolean(is_link)
end