Module: Strokes::ActiveRecord::ClassMethods

Defined in:
lib/strokes/active_record.rb

Instance Method Summary collapse

Instance Method Details

#has_barcode(format, value, versions = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/strokes/active_record.rb', line 14

def has_barcode(format, value, versions = {})
  after_create  :create_barcodes
  after_destroy :delete_barcodes

  class_eval <<-RUBY, __FILE__, __LINE__+1
    private
    
    def _barcode_format
      respond_to?(:#{format}, true) ? send(:#{format}) : :#{format}
    end

    def _barcode_value
      send(:#{value})
    end
    
    def _barcode_versions
      #{versions.inspect}
    end
  RUBY
end