17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/field_mapper/custom/plat.rb', line 17
def field(
name,
type: nil,
desc: nil,
default: nil,
placeholder: nil,
standard: nil,
custom_to_standard: FieldMapper::Custom::Field::DefaultFlipper,
standard_to_custom: FieldMapper::Custom::Field::DefaultFlipper,
&block
)
field_names[attr_name(name)] = name
field = fields[name] = FieldMapper::Custom::Field.new(
name,
type: type,
desc: desc,
default: default,
placeholder: placeholder,
standard_field: standard_plat.fields[standard],
custom_to_standard: custom_to_standard,
standard_to_custom: standard_to_custom
)
field.instance_exec(&block) if block_given?
define_method(attr_name name) do
self[name]
end
define_method("#{attr_name name}=") do |value|
self[name] = value
end
define_method("custom_to_standard_#{name}", &custom_to_standard)
define_method("standard_to_custom_#{name}", &standard_to_custom)
end
|