55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/subroutine/fields.rb', line 55
def fields_from(*things)
options = things.
excepts = options.key?(:except) ? Array(options.delete(:except)) : nil
onlys = options.key?(:only) ? Array(options.delete(:only)) : nil
things.each do |thing|
local_excepts = excepts.map { |field| thing.get_field_config(field)&.related_field_names }.flatten.compact.uniq if excepts
local_onlys = onlys.map { |field| thing.get_field_config(field)&.related_field_names }.flatten.compact.uniq if onlys
thing.field_configurations.each_pair do |field_name, config|
next if local_excepts&.include?(field_name)
next if local_onlys && !local_onlys.include?(field_name)
config.required_modules.each do |mod|
include mod unless included_modules.include?(mod)
end
field(field_name, config.merge(options))
end
end
end
|