Sha256: e5e4c71754da0fcda64fcee29a291f894e64839167fdb6b809e42ebe335bdff3

Contents?: true

Size: 276 Bytes

Versions: 5

Compression:

Stored size: 276 Bytes

Contents

# frozen_string_literal: true

module DecoLite
  # Provides methods to convert the object to a Hash.
  module Hashable
    def to_h
      field_names.each.each_with_object({}) do |field_name, hash|
        hash[field_name] = public_send field_name
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
deco_lite-0.2.5 lib/deco_lite/hashable.rb
deco_lite-0.2.4 lib/deco_lite/hashable.rb
deco_lite-0.2.3 lib/deco_lite/hashable.rb
deco_lite-0.2.2 lib/deco_lite/hashable.rb
deco_lite-0.1.1 lib/deco_lite/hashable.rb