Sha256: 4801c00524a58879b0af8871e2e34ad1dd8f934ee13687d27a8514dbb5c3f3ed

Contents?: true

Size: 1.35 KB

Versions: 21

Compression:

Stored size: 1.35 KB

Contents

# -*- ruby -*-

module PG

	class Coder

		module BinaryFormatting
			Params = { format: 1 }
			def initialize( params={} )
				super(params.merge(Params))
			end
		end


		# Create a new coder object based on the attribute Hash.
		def initialize(params={})
			params.each do |key, val|
				send("#{key}=", val)
			end
		end

		def dup
			self.class.new(to_h)
		end

		# Returns coder attributes as Hash.
		def to_h
			{
				oid: oid,
				format: format,
				name: name,
			}
		end

		def ==(v)
			self.class == v.class && to_h == v.to_h
		end

		def marshal_dump
			Marshal.dump(to_h)
		end

		def marshal_load(str)
			initialize Marshal.load(str)
		end

		def inspect
			str = self.to_s
			oid_str = " oid=#{oid}" unless oid==0
			format_str = " format=#{format}" unless format==0
			name_str = " #{name.inspect}" if name
			str[-1,0] = "#{name_str} #{oid_str}#{format_str}"
			str
		end
	end

	class CompositeCoder < Coder
		def to_h
			super.merge!({
				elements_type: elements_type,
				needs_quotation: needs_quotation?,
				delimiter: delimiter,
			})
		end

		def inspect
			str = super
			str[-1,0] = " elements_type=#{elements_type.inspect} #{needs_quotation? ? 'needs' : 'no'} quotation"
			str
		end
	end

	class CopyCoder < Coder
		def to_h
			super.merge!({
				type_map: type_map,
				delimiter: delimiter,
				null_string: null_string,
			})
		end
	end
end # module PG

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pg-1.1.4-x86-mingw32 lib/pg/coder.rb
pg-1.1.4-x64-mingw32 lib/pg/coder.rb
pg-1.1.4 lib/pg/coder.rb
pg-1.1.3-x86-mingw32 lib/pg/coder.rb
pg-1.1.3-x64-mingw32 lib/pg/coder.rb
pg-1.1.3 lib/pg/coder.rb
pg-1.1.2-x86-mingw32 lib/pg/coder.rb
pg-1.1.2-x64-mingw32 lib/pg/coder.rb
pg-1.1.2 lib/pg/coder.rb
pg-1.1.1-x86-mingw32 lib/pg/coder.rb
pg-1.1.1-x64-mingw32 lib/pg/coder.rb
pg-1.1.1 lib/pg/coder.rb
pg-1.1.0-x86-mingw32 lib/pg/coder.rb
pg-1.1.0-x64-mingw32 lib/pg/coder.rb
pg-1.1.0 lib/pg/coder.rb
pg-1.1.0.pre20180730171000-x86-mingw32 lib/pg/coder.rb
pg-1.1.0.pre20180730171000-x64-mingw32 lib/pg/coder.rb
pg-1.1.0.pre20180730171000 lib/pg/coder.rb
pg-1.1.0.pre20180730144600-x86-mingw32 lib/pg/coder.rb
pg-1.1.0.pre20180730144600-x64-mingw32 lib/pg/coder.rb