Sha256: 7f39604409ea194cf4f4f7933851c10bc596908404c1d22b95f9a8e7d168a4eb

Contents?: true

Size: 412 Bytes

Versions: 16

Compression:

Stored size: 412 Bytes

Contents

require 'json'

module DataSeeder
  module Loader
    class JSON
      include Loader
      def load(io)
        json = ::JSON.parse(io.read)
        if json.kind_of?(Hash)
          json.each do |key, attr|
            attr[self.key_attribute] = key if self.key_attribute
            save(attr)
          end
        else
          Array(json).each { |attr| save(attr) }
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
data_seeder-1.1.0 lib/data_seeder/loader/json.rb
data_seeder-1.0.9 lib/data_seeder/loader/json.rb
data_seeder-1.0.8 lib/data_seeder/loader/json.rb
data_seeder-1.0.7 lib/data_seeder/loader/json.rb
data_seeder-1.0.6 lib/data_seeder/loader/json.rb
data_seeder-1.0.5 lib/data_seeder/loader/json.rb
data_seeder-1.0.4 lib/data_seeder/loader/json.rb
data_seeder-1.0.3 lib/data_seeder/loader/json.rb
data_seeder-1.0.2 lib/data_seeder/loader/json.rb
data_seeder-1.0.1 lib/data_seeder/loader/json.rb
data_seeder-1.0.0 lib/data_seeder/loader/json.rb
data_seeder-0.0.5 lib/data_seeder/loader/json.rb
data_seeder-0.0.4 lib/data_seeder/loader/json.rb
data_seeder-0.0.3 lib/data_seeder/loader/json.rb
data_seeder-0.0.2 lib/data_seeder/loader/json.rb
data_seeder-0.0.1 lib/data_seeder/loader/json.rb