Class: ActiveRecord::Fixtures::File
- Includes:
- Enumerable
- Defined in:
- activerecord/lib/active_record/fixtures/file.rb
Constant Summary collapse
- RESCUE_ERRORS =
:nodoc:
[ ArgumentError ]
Class Method Summary collapse
-
.open(file) ⇒ Object
Open a fixture file named
file
.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(file) ⇒ File
constructor
A new instance of File.
Methods included from Enumerable
#as_json, #each_with_object, #exclude?, #group_by, #index_by, #many?, #sum
Constructor Details
#initialize(file) ⇒ File
Returns a new instance of File.
23 24 25 26 |
# File 'activerecord/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 'activerecord/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 'activerecord/lib/active_record/fixtures/file.rb', line 28 def each(&block) rows.each(&block) end |