16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/has_barcode.rb', line 16
def has_barcode(*args)
options = args.
@@barcode_configurations ||= {}
@@barcode_configurations[args.first] = HasBarcode::Configuration.new(options)
define_method args.first do
if options[:type] == :code_128
@@barcode_configurations[args.first].barcode_class.new(options[:value].call(self), 'A')
else
@@barcode_configurations[args.first].barcode_class.new(options[:value].call(self))
end
end
define_method "#{args.first}_data" do |*meth_args|
if meth_args
send(args.first).send("to_#{options[:outputter]}", *meth_args)
else
send(args.first).send("to_#{options[:outputter]}")
end
end
end
|