25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'app/models/picto_element.rb', line 25
def self.method_missing(m, *args)
if args.size == 1
match = /_\w*_/.match m
if match
type = match.to_a[0]
type.chop!.slice!(0)
picto_hash = args[0].merge(category: type.parameterize.underscore.to_sym)
PictoElement.create(picto_hash)
end
elsif args.size.zero?
match = /_\w*/.match m
if match
type = match.to_a[0]
type.slice!(0)
PictoQuery
.new
.from_category(type.parameterize.underscore.to_sym)
.to_a
end
end
end
|