Sha256: ae626a5949fb22e562c150fde46d4c3854634aac47dadfc257fad3b015ed990d
Contents?: true
Size: 1.08 KB
Versions: 10
Compression:
Stored size: 1.08 KB
Contents
# Enable OpenStruct support in awesome print # Code from @marshallshen https://github.com/michaeldv/awesome_print/pull/145 # # Copyright (c) 2010-2013 Michael Dvorkin # # Awesome Print is freely distributable under the terms of MIT license. # See LICENSE file or http://www.opensource.org/licenses/mit-license.php #------------------------------------------------------------------------------ if defined?(OpenStruct) module AwesomePrint module OpenStruct def self.included(base) base.send :alias_method, :cast_without_ostruct, :cast base.send :alias_method, :cast, :cast_with_ostruct end def cast_with_ostruct(object, type) cast = cast_without_ostruct(object, type) if (defined?(::OpenStruct)) && (object.is_a?(::OpenStruct)) cast = :open_struct_instance end cast end def awesome_open_struct_instance(object) "#{object.class} #{awesome_hash(object.marshal_dump)}" end end # module OpenStruct end # module AwesomePrint AwesomePrint::Formatter.send(:include, AwesomePrint::OpenStruct) end
Version data entries
10 entries across 10 versions & 1 rubygems