File: pretty_inspect.rb

package info (click to toggle)
ruby-hashie 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: ruby: 7,049; sh: 8; makefile: 6
file content (19 lines) | stat: -rw-r--r-- 435 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Hashie
  module Extensions
    module PrettyInspect
      def self.included(base)
        base.send :alias_method, :hash_inspect, :inspect
        base.send :alias_method, :inspect, :hashie_inspect
      end

      def hashie_inspect
        ret = "#<#{self.class}"
        keys.sort_by(&:to_s).each do |key|
          ret << " #{key}=#{self[key].inspect}"
        end
        ret << '>'
        ret
      end
    end
  end
end