65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/redis_object/ext/views.rb', line 65
def normalize_field_options(fields)
fields.flatten!
fields.uniq!
options = {}
if fields.last.is_a?(Hash) options.merge!(fields.slice!(fields.size - 1, 1)[0])
end
if options.keys.size > 0 and options[:method]
out = options[:method].to_sym
else
hash = fields.select {|f| f.is_a?(Hash) }.inject({},:merge)
out = {}
if (h = hash.select {|k,v| !v.is_a?(Proc) }) && h.count > 0
out[:hashes] = h
end
if (h = hash.select {|k,v| v.is_a?(Proc) }) && h.count > 0
out[:procs] = h
end
if (h = fields.select {|o| o.is_a?(String) || o.is_a?(Symbol) }) && h.count > 0
out[:fields] = h
end
end
out
end
|