X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factionpack%2Flib%2Faction_view%2Fhelpers%2Fdebug_helper.rb;fp=vendor%2Frails%2Factionpack%2Flib%2Faction_view%2Fhelpers%2Fdebug_helper.rb;h=90863fca08d0e18c54861dc418128aeda59b4f1a;hb=437aa336c44c74a30aeea16a06743c32747ed661;hp=0000000000000000000000000000000000000000;hpb=97a0772b06264134cfe38e7494f9427efe0840a0;p=feedcatcher.git diff --git a/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb b/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb new file mode 100644 index 0000000..90863fc --- /dev/null +++ b/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb @@ -0,0 +1,38 @@ +module ActionView + module Helpers + # Provides a set of methods for making it easier to debug Rails objects. + module DebugHelper + # Returns a YAML representation of +object+ wrapped with
 and 
. + # If the object cannot be converted to YAML using +to_yaml+, +inspect+ will be called instead. + # Useful for inspecting an object at the time of rendering. + # + # ==== Example + # + # @user = User.new({ :username => 'testing', :password => 'xyz', :age => 42}) %> + # debug(@user) + # # => + #
--- !ruby/object:User
+      #   attributes:
+      #     updated_at:
+      #     username: testing
+      #
+      #     age: 42
+      #     password: xyz
+      #     created_at:
+      #   attributes_cache: {}
+      #
+      #   new_record: true
+      #   
+ + def debug(object) + begin + Marshal::dump(object) + "
#{h(object.to_yaml).gsub("  ", "  ")}
" + rescue Exception => e # errors from Marshal or YAML + # Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback + "#{h(object.inspect)}" + end + end + end + end +end