1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00
awesome_print/lib/ap/mixin/active_support.rb

34 lines
1.1 KiB
Ruby
Raw Normal View History

# Copyright (c) 2010 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
#------------------------------------------------------------------------------
module AwesomePrintActiveSupport
def self.included(base)
base.send :alias_method, :printable_without_active_support, :printable
base.send :alias_method, :printable, :printable_with_active_support
end
# Add ActiveSupport class names to the dispatcher pipeline.
#------------------------------------------------------------------------------
def printable_with_active_support(object)
printable = printable_without_active_support(object)
if printable == :self
if object.is_a?(ActiveSupport::TimeWithZone)
printable = :active_support_time
end
end
printable
end
# Format ActiveSupport::TimeWithZone as standard Time.
#------------------------------------------------------------------------------
def awesome_active_support_time(object)
awesome_self(object, :as => :time)
end
end
AwesomePrint.send(:include, AwesomePrintActiveSupport)