Sha256: be5142255782a4f0a37cc6054f1e73add727861cfc192393f622a8918441d1f2

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module Mwc
  module Utils
    # Provide Hash-like accessor
    module HashAccessor
      # Hash-like getter
      #
      # @param name [String|Symbol] the option name
      #
      # @since 0.3.0
      # @api private
      def [](name)
        return unless respond_to?(name)

        send(name)
      end

      # Hash-like setter
      #
      # @param name [String|Symbol] the option name
      # @param value [Object] the option value
      #
      # @since 0.3.0
      # @api private
      def []=(name, value)
        return unless respond_to?("#{name}=")

        send("#{name}=", value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mwc-0.4.0 lib/mwc/utils/hash_accessor.rb
mwc-0.3.0 lib/mwc/utils/hash_accessor.rb