Sha256: 21590e92c8d50bb2ca5c7454f89059c79bc596a90a779aa9ea46d327df8962d2

Contents?: true

Size: 665 Bytes

Versions: 9

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

module MiniSql
  module Result
    # AM serializer support
    alias :read_attribute_for_serialization :send

    def to_h
      r = {}
      instance_variables.each do |f|
        r[f.to_s.delete_prefix('@').to_sym] = instance_variable_get(f)
      end
      r
    end

    def values
      instance_variables.map { |f| instance_variable_get(f) }
    end

    def ==(other_result)
      self.class.decorator == other_result.class.decorator &&
      self.instance_variables == other_result.instance_variables &&
      self.values == other_result.values
    end

    def eql?(other_result)
      self == other_result
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mini_sql-1.6.0 lib/mini_sql/result.rb
mini_sql-1.5.0 lib/mini_sql/result.rb
mini_sql-1.4.0 lib/mini_sql/result.rb
mini_sql-1.3.0 lib/mini_sql/result.rb
mini_sql-1.2.0 lib/mini_sql/result.rb
mini_sql-1.1.3 lib/mini_sql/result.rb
mini_sql-1.1.2 lib/mini_sql/result.rb
mini_sql-1.1.1 lib/mini_sql/result.rb
mini_sql-1.1.0 lib/mini_sql/result.rb