Sha256: 2c6d8140985aa162a243708872c7fe0abe79ea91a681e5d9efb749053b9b4a5a

Contents?: true

Size: 562 Bytes

Versions: 2

Compression:

Stored size: 562 Bytes

Contents

module RubyApp

  module Mixins

    module HashMixin

      def method_missing(name, *arguments)
        if name.to_s.match(/(.*)=/)
          capture = $~.captures[0]
          self[capture.to_sym] = arguments[0]
        else
          self[name.to_sym]
        end
      end

    end

  end

end

class Hash
  include RubyApp::Mixins::HashMixin

  def symbolize_keys!
    copy=self.dup
    self.clear
    copy.each do |name, value|
      if value.is_a?(Hash)
        value.symbolize_keys!
      end
      self[name.to_sym] = value
    end
    self
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
RubyApp-0.0.82 lib/ruby_app/mixins/hash_mixin.rb
RubyApp-0.0.81 lib/ruby_app/mixins/hash_mixin.rb