Module: Ronin::Model::Importable::ClassMethods
- Defined in:
- lib/ronin/model/importable.rb
Overview
Instance Method Summary collapse
-
#import(path) {|resource| ... } ⇒ Array<Model>
Extracts and imports resources from the given file.
Instance Method Details
#import(path) {|resource| ... } ⇒ Array<Model>
Extracts and imports resources from the given file.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ronin/model/importable.rb', line 51 def import(path) return enum_for(:import,path).to_a unless block_given? File.open(path) do |file| file.each_line do |line| extract(line) do |resource| yield(resource) if resource.save end end end end |