File: active_record_data.rb

package info (click to toggle)
ruby-awesome-print 1.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 652 kB
  • sloc: ruby: 3,827; makefile: 6
file content (20 lines) | stat: -rw-r--r-- 576 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'pathname'

class ActiveRecordData
  class << self
    data_file_selector = Pathname(File.dirname(__FILE__)).join('active_record_data', '*.txt')

    # Example generated method
    # data_filename = '/path/to/ap/spec/support/active_record_data/4_2_diana.txt'
    #
    # def self.raw_4_2_dana
    #   File.read(data_filename).strip
    # end
    Dir[data_file_selector].each do |data_filename|
      method_name = Pathname(data_filename).basename('.txt')
      define_method(:"raw_#{method_name}") do
        File.read(data_filename).strip
      end
    end
  end
end