Sha256: e723633f485db6eb74fb8a5b9180cc9e5648b6c8ba9cda1449f1b09a60b9d7c7

Contents?: true

Size: 1.79 KB

Versions: 79

Compression:

Stored size: 1.79 KB

Contents

module CipherStashPG
  class Coder
    module BinaryFormatting
      Params = { :format => 1 }
      
      def initialize(params = {})
        super(Params.merge(params))
      end
    end
    
    def initialize(params = {})
      params.each { |key, val| send("#{key}=", val) }
    end
    
    def dup
      self.class.new(to_h)
    end
    
    def to_h
      { :oid => oid, :format => format, :flags => flags, :name => name }
    end
    
    def ==(v)
      (self.class == v.class) and (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
    
    def inspect_short
      str = case format
      when 0 then
        "T"
      when 1 then
        "B"
      else
        format.to_s
      end
      str = (str + "E") if respond_to?(:encode)
      str = (str + "D") if respond_to?(:decode)
      "#{(name or self.class.name)}:#{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
  
  class RecordCoder < Coder
    def to_h
      super.merge!(:type_map => type_map)
    end
  end
end

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
cipherstash-pg-1.0.0.beta.22-x86_64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.22-x86_64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.22-arm64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.22-aarch64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.21-x86_64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.21-aarch64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.21-arm64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.21-x86_64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.19-x86_64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.19-x86_64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.19-arm64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.19-aarch64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.18-x86_64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.18-x86_64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.18-arm64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.18-aarch64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.17-aarch64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.17-x86_64-darwin ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.17-x86_64-linux ./lib/cipherstash-pg/coder.rb
cipherstash-pg-1.0.0.beta.17-arm64-darwin ./lib/cipherstash-pg/coder.rb