aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/extending.rb
diff options
context:
space:
mode:
authorSam Stephenson <sam@37signals.com>2007-03-18 07:05:58 +0000
committerSam Stephenson <sam@37signals.com>2007-03-18 07:05:58 +0000
commit3202fbabe6df3591d7e2c35727ea9c8b68df8828 (patch)
treec55f19f82564280e074d9aca449ee4848a97f158 /activesupport/lib/active_support/core_ext/object/extending.rb
parent3d5c947155934fb498f8788a204ae9f2e03f2f42 (diff)
downloadrails-3202fbabe6df3591d7e2c35727ea9c8b68df8828.tar.gz
rails-3202fbabe6df3591d7e2c35727ea9c8b68df8828.tar.bz2
rails-3202fbabe6df3591d7e2c35727ea9c8b68df8828.zip
Refactor ActiveSupport::JSON to be less obtuse. Add support for JSON decoding by way of Syck with ActiveSupport::JSON.decode(json_string). Prevent hash keys that are JavaScript reserved words from being unquoted during encoding.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6443 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/extending.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/extending.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/extending.rb b/activesupport/lib/active_support/core_ext/object/extending.rb
index 8a82f71c0f..0815909410 100644
--- a/activesupport/lib/active_support/core_ext/object/extending.rb
+++ b/activesupport/lib/active_support/core_ext/object/extending.rb
@@ -1,9 +1,9 @@
-class Object #:nodoc:
- def remove_subclasses_of(*superclasses)
+class Object
+ def remove_subclasses_of(*superclasses) #:nodoc:
Class.remove_class(*subclasses_of(*superclasses))
end
- def subclasses_of(*superclasses)
+ def subclasses_of(*superclasses) #:nodoc:
subclasses = []
ObjectSpace.each_object(Class) do |k|
next unless # Exclude this class unless
@@ -16,23 +16,23 @@ class Object #:nodoc:
subclasses
end
- def extended_by
+ def extended_by #:nodoc:
ancestors = class << self; ancestors end
ancestors.select { |mod| mod.class == Module } - [ Object, Kernel ]
end
- def copy_instance_variables_from(object, exclude = [])
+ def copy_instance_variables_from(object, exclude = []) #:nodoc:
exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables
instance_variables = object.instance_variables - exclude.map { |name| name.to_s }
instance_variables.each { |name| instance_variable_set(name, object.instance_variable_get(name)) }
end
- def extend_with_included_modules_from(object)
+ def extend_with_included_modules_from(object) #:nodoc:
object.extended_by.each { |mod| extend mod }
end
- def instance_values
+ def instance_values #:nodoc:
instance_variables.inject({}) do |values, name|
values[name[1..-1]] = instance_variable_get(name)
values
@@ -40,7 +40,7 @@ class Object #:nodoc:
end
unless defined? instance_exec # 1.9
- def instance_exec(*arguments, &block)
+ def instance_exec(*arguments, &block) #:nodoc:
block.bind(self)[*arguments]
end
end