Class: ActiveRecord::Fixtures::File

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_record/fixtures/file.rb

Constant Summary collapse

RESCUE_ERRORS =

:nodoc:

[ ArgumentError ]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ File

Returns a new instance of File.



23
24
25
26
# File 'lib/active_record/fixtures/file.rb', line 23

def initialize(file)
  @file = file
  @rows = nil
end

Class Method Details

.open(file) ⇒ Object

Open a fixture file named file. When called with a block, the block is called with the filehandle and the filehandle is automatically closed when the block finishes.



18
19
20
21
# File 'lib/active_record/fixtures/file.rb', line 18

def self.open(file)
  x = new file
  block_given? ? yield(x) : x
end

Instance Method Details

#each(&block) ⇒ Object



28
29
30
# File 'lib/active_record/fixtures/file.rb', line 28

def each(&block)
  rows.each(&block)
end