Class: ActiveElement::Components::Util::FormValueMapping
- Inherits:
-
Object
- Object
- ActiveElement::Components::Util::FormValueMapping
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
RecordMapping::DATABASE_TYPES
Instance Method Summary
collapse
#initialize, #type, #value
Instance Method Details
#boolean_value ⇒ Object
34
35
36
|
# File 'lib/active_element/components/util/form_value_mapping.rb', line 34
def boolean_value
value_from_record
end
|
#date_value ⇒ Object
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_value ⇒ Object
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_value ⇒ Object
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_value ⇒ Object
14
15
16
|
# File 'lib/active_element/components/util/form_value_mapping.rb', line 14
def json_value
value_from_record
end
|
#numeric_value ⇒ Object
10
11
12
|
# File 'lib/active_element/components/util/form_value_mapping.rb', line 10
def numeric_value
value_from_record
end
|
#string_value ⇒ Object
18
19
20
|
# File 'lib/active_element/components/util/form_value_mapping.rb', line 18
def string_value
value_from_record
end
|
#time_value ⇒ Object
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
|