Sha256: aefb22c2b6aba6aaf253ec6d25d9b1b4c572e1f7a3546a11f3bafa64c55f39bc

Contents?: true

Size: 321 Bytes

Versions: 8

Compression:

Stored size: 321 Bytes

Contents

# frozen_string_literal: true

module ISO3166
  class KwargStruct < Struct
    # Override the initialize to handle hashes of named parameters
    def initialize(*args)
      opts = args.last.is_a?(Hash) ? args.pop : {}
      super(*args)
      opts.each_pair do |k, v|
        send "#{k}=", v
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
countries-5.2.1 lib/countries/kwarg_struct.rb
countries-5.2.0 lib/countries/kwarg_struct.rb
countries-5.1.2 lib/countries/kwarg_struct.rb
countries-5.1.1 lib/countries/kwarg_struct.rb
countries-5.1.0 lib/countries/kwarg_struct.rb
countries-5.0.2 lib/countries/kwarg_struct.rb
countries-5.0.1 lib/countries/kwarg_struct.rb
countries-5.0.0 lib/countries/kwarg_struct.rb