lib/psychic/util.rb in psychic-runner-0.0.2 vs lib/psychic/util.rb in psychic-runner-0.0.3
- old
+ new
@@ -1,8 +1,15 @@
module Psychic
autoload :RegexpTokenHandler, 'psychic/tokens'
autoload :MustacheTokenHandler, 'psychic/tokens'
class Util
+ module Hashable
+ def to_hash
+ instance_variables.each_with_object({}) do |var,hash|
+ hash[var.to_s.delete("@")] = instance_variable_get(var)
+ end
+ end
+ end
# Returns a new Hash with all key values coerced to strings. All keys
# within a Hash are coerced by calling #to_s and hashes with arrays
# and other hashes are traversed.
#
# @param obj [Object] the hash to be processed. While intended for