13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/lolita/configuration/factory/field.rb', line 13
def create(dbi,*args,&block)
options = args ? args. : {}
dbi_field = options[:dbi_field]
name = args[0] || options[:name] || (dbi_field ? dbi_field.name : nil)
dbi_field ||= dbi.field_by_name(name)
dbi_field ||= dbi.field_by_association(name)
association ||= detect_association(dbi,name)
type = args[1] || options[:type] ||
(association ? :array : nil ) ||
(dbi_field ? dbi_field.type : nil) ||
:string
options[:dbi_field] = dbi_field
if !name || !type
raise Lolita::FieldTypeError, "type not defined. Set is as second argument or as :dbi_field where value is Adapter::[ORM]::Field object."
else
field_class(type).new(dbi,name,type,options,&block)
end
end
|