Files

AwesomePrintActiveSupport

Copyright (c) 2010-2011 Michael Dvorkin

Awesome Print is freely distributable under the terms of MIT license. See LICENSE file or www.opensource.org/licenses/mit-license.php

Public Class Methods

included(base) click to toggle source
# File lib/ap/mixin/active_support.rb, line 8
def self.included(base)
  base.send :alias_method, :printable_without_active_support, :printable
  base.send :alias_method, :printable, :printable_with_active_support
end

Public Instance Methods

awesome_active_support_time(object) click to toggle source

Format ActiveSupport::TimeWithZone as standard Time.

# File lib/ap/mixin/active_support.rb, line 31
def awesome_active_support_time(object)
  awesome_self(object, :as => :time)
end
awesome_hash_with_indifferent_access(object) click to toggle source

Format HashWithIndifferentAccess as standard Hash.

NOTE: can't use awesome_self(object, :as => :hash) since awesome_self uses object.inspect internally, i.e. it would convert hash to string.

# File lib/ap/mixin/active_support.rb, line 40
def awesome_hash_with_indifferent_access(object)
  awesome_hash(object)
end
printable_with_active_support(object) click to toggle source

Add ActiveSupport class names to the dispatcher pipeline.

# File lib/ap/mixin/active_support.rb, line 15
def printable_with_active_support(object)
  printable = printable_without_active_support(object)
  return printable if !defined?(ActiveSupport::TimeWithZone) || !defined?(HashWithIndifferentAccess)

  if printable == :self
    if object.is_a?(ActiveSupport::TimeWithZone)
      printable = :active_support_time
    elsif object.is_a?(HashWithIndifferentAccess)
      printable = :hash_with_indifferent_access
    end
  end
  printable
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.