32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/subroutine/fields.rb', line 32
def field(field_name, options = {})
config = ::Subroutine::Fields::Configuration.from(field_name, options)
config.validate!
self.field_configurations = field_configurations.merge(field_name.to_sym => config)
ensure_field_accessors(config)
if config.groups.any?
new_fields_by_group = self.fields_by_group.deep_dup
config.groups.each do |group_name|
new_fields_by_group[group_name] << config.field_name
ensure_group_accessors(group_name)
end
self.fields_by_group = new_fields_by_group
end
config
end
|