aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object_and_class.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object_and_class.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object_and_class.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object_and_class.rb b/activesupport/lib/active_support/core_ext/object_and_class.rb
index aef1f22c6f..4856a9f5d5 100644
--- a/activesupport/lib/active_support/core_ext/object_and_class.rb
+++ b/activesupport/lib/active_support/core_ext/object_and_class.rb
@@ -54,6 +54,17 @@ class Object #:nodoc:
def with_options(options)
yield ActiveSupport::OptionMerger.new(self, options)
end
+
+ def instance_values
+ instance_variables.inject({}) do |values, name|
+ values[name[1..-1]] = instance_variable_get(name)
+ values
+ end
+ end
+
+ def to_json
+ ActiveSupport::JSON.encode(self)
+ end
end
class Class #:nodoc: