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
|
# File 'app/models/effective/model_reader.rb', line 23
def method_missing(m, *args, &block)
if m == :timestamps
attributes[:created_at] = [:datetime]
attributes[:updated_at] = [:datetime]
return
end
if args.first.kind_of?(Hash) && args.first.key?(:permitted)
args.unshift(:permitted_param)
end
if args.first.kind_of?(Array)
options = args.find { |arg| arg.kind_of?(Hash) } || { permitted: true }
args = [:permitted_param, options.merge(permitted_attributes: args.first)]
end
unless DATATYPES.include?(args.first)
raise "expected first argument to be a datatype. Try name :string"
end
attributes[m] = args
end
|