Module: Strokes::ActiveRecord

Defined in:
lib/strokes/active_record.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



8
9
10
# File 'lib/strokes/active_record.rb', line 8

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#barcode(version = nil) ⇒ Object



46
47
48
# File 'lib/strokes/active_record.rb', line 46

def barcode(version = nil)
  File.open(barcode_filename(version))
end

#barcode_filename(version = nil) ⇒ Object



41
42
43
44
# File 'lib/strokes/active_record.rb', line 41

def barcode_filename(version = nil)
  filename = version ? "#{id}_#{version}" : "#{id}"
  "#{barcode_path}/#{filename}.png"
end

#barcode_pathObject



37
38
39
# File 'lib/strokes/active_record.rb', line 37

def barcode_path
  "#{Rails.root}/barcodes/#{self.class.to_s.tableize}"
end