Class: ActiveElement::Components::Util::FormValueMapping

Inherits:
Object
  • Object
show all
Includes:
RecordMapping
Defined in:
lib/active_element/components/util/form_value_mapping.rb

Overview

Maps ActiveRecord record fields to values for editing in forms.

Constant Summary

Constants included from RecordMapping

RecordMapping::DATABASE_TYPES

Instance Method Summary collapse

Methods included from RecordMapping

#initialize, #type, #value

Instance Method Details

#boolean_valueObject



34
35
36
# File 'lib/active_element/components/util/form_value_mapping.rb', line 34

def boolean_value
  value_from_record
end

#date_valueObject



30
31
32
# File 'lib/active_element/components/util/form_value_mapping.rb', line 30

def date_value
  with_timezone_offset(value_from_record).strftime('%Y-%m-%d')
end

#datetime_valueObject



22
23
24
# File 'lib/active_element/components/util/form_value_mapping.rb', line 22

def datetime_value
  with_timezone_offset(value_from_record).strftime('%Y-%m-%d %H:%M:%S')
end

#geometry_valueObject



38
39
40
41
# File 'lib/active_element/components/util/form_value_mapping.rb', line 38

def geometry_value
  require 'rgeo/geo_json'
  RGeo::GeoJSON.encode(value_from_record).to_json
end

#json_valueObject



14
15
16
# File 'lib/active_element/components/util/form_value_mapping.rb', line 14

def json_value
  value_from_record
end

#numeric_valueObject



10
11
12
# File 'lib/active_element/components/util/form_value_mapping.rb', line 10

def numeric_value
  value_from_record
end

#string_valueObject



18
19
20
# File 'lib/active_element/components/util/form_value_mapping.rb', line 18

def string_value
  value_from_record
end

#time_valueObject



26
27
28
# File 'lib/active_element/components/util/form_value_mapping.rb', line 26

def time_value
  with_timezone_offset(value_from_record).strftime('%H:%M:%S')
end