mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Symbol#[] method presents in Ruby 1.9
This commit is contained in:
parent
8c63e7d35d
commit
5215eed5a3
3 changed files with 4 additions and 4 deletions
|
@ -121,7 +121,7 @@ module AbstractController
|
|||
variables = instance_variables
|
||||
variables -= protected_instance_variables
|
||||
variables -= DEFAULT_PROTECTED_INSTANCE_VARIABLES
|
||||
variables.each { |name| hash[name.to_s[1, name.length]] = instance_variable_get(name) }
|
||||
variables.each { |name| hash[name[1..-1]] = instance_variable_get(name) }
|
||||
hash
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class Object
|
|||
#
|
||||
# C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
|
||||
def instance_values #:nodoc:
|
||||
Hash[instance_variables.map { |name| [name.to_s[1..-1], instance_variable_get(name)] }]
|
||||
Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }]
|
||||
end
|
||||
|
||||
# Returns an array of instance variable names including "@". They are strings
|
||||
|
|
|
@ -11,8 +11,8 @@ module ActiveSupport
|
|||
#
|
||||
class StringInquirer < String
|
||||
def method_missing(method_name, *arguments)
|
||||
if method_name.to_s[-1,1] == "?"
|
||||
self == method_name.to_s[0..-2]
|
||||
if method_name[-1, 1] == "?"
|
||||
self == method_name[0..-2]
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue