Sha256: 24ebe96611d5d010ca795c65786f29918a478bf661833de23a958ef29c1bf9c4

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

%w{
  active_support/json/encoding
}.each do |active_support_3_requirement|
  require active_support_3_requirement
end if ::ActiveSupport::VERSION::MAJOR == 3

module Mysql2xxxx
  class JSON
    include ExtraOutputs
    
    attr_reader :properties
    
    def initialize(options = {})
      @properties = Properties.new options
    end
    
    def client
      @client ||= Client.new properties
    end

    def to_file(f)
      first = true
      f.write '['
      client.select_each(properties.execute) do |hsh|
        line = if first
          first = false
          hsh.to_json
        else
          ',' + hsh.to_json
        end
        f.write line
      end
      f.write ']'
      nil
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mysql2xxxx-0.0.2 lib/mysql2xxxx/json.rb
mysql2xxxx-0.0.1 lib/mysql2xxxx/json.rb