mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix stack trace lines on class_eval
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
8b2266a8da
commit
13e00ce606
15 changed files with 29 additions and 29 deletions
|
@ -120,7 +120,7 @@ module ActionController
|
|||
end
|
||||
|
||||
%w(edit new).each do |action|
|
||||
module_eval <<-EOT, __FILE__, __LINE__
|
||||
module_eval <<-EOT, __FILE__, __LINE__ + 1
|
||||
def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
|
||||
polymorphic_url( # polymorphic_url(
|
||||
record_or_hash, # record_or_hash,
|
||||
|
|
|
@ -1105,7 +1105,7 @@ module ActionView
|
|||
end
|
||||
|
||||
(field_helpers - %w(label check_box radio_button fields_for hidden_field)).each do |selector|
|
||||
src, file, line = <<-end_src, __FILE__, __LINE__ + 1
|
||||
src, line = <<-end_src, __LINE__ + 1
|
||||
def #{selector}(method, options = {}) # def text_field(method, options = {})
|
||||
@template.send( # @template.send(
|
||||
#{selector.inspect}, # "text_field",
|
||||
|
@ -1114,7 +1114,7 @@ module ActionView
|
|||
objectify_options(options)) # objectify_options(options))
|
||||
end # end
|
||||
end_src
|
||||
class_eval src, file, line
|
||||
class_eval src, __FILE__, line
|
||||
end
|
||||
|
||||
def fields_for(record_or_name_or_array, *args, &block)
|
||||
|
|
|
@ -1314,12 +1314,12 @@ class FormHelperTest < ActionView::TestCase
|
|||
|
||||
class LabelledFormBuilder < ActionView::Helpers::FormBuilder
|
||||
(field_helpers - %w(hidden_field)).each do |selector|
|
||||
src = <<-END_SRC
|
||||
src, line = <<-END_SRC, __LINE__ + 1
|
||||
def #{selector}(field, *args, &proc)
|
||||
("<label for='\#{field}'>\#{field.to_s.humanize}:</label> " + super + "<br/>").html_safe
|
||||
end
|
||||
END_SRC
|
||||
class_eval src, __FILE__, __LINE__
|
||||
class_eval src, __FILE__, line
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ module ActiveModel
|
|||
|
||||
def alias_attribute(new_name, old_name)
|
||||
attribute_method_matchers.each do |matcher|
|
||||
module_eval <<-STR, __FILE__, __LINE__+1
|
||||
module_eval <<-STR, __FILE__, __LINE__ + 1
|
||||
def #{matcher.method_name(new_name)}(*args)
|
||||
send(:#{matcher.method_name(old_name)}, *args)
|
||||
end
|
||||
|
@ -265,7 +265,7 @@ module ActiveModel
|
|||
else
|
||||
method_name = matcher.method_name(attr_name)
|
||||
|
||||
generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__+1
|
||||
generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
|
||||
if method_defined?(:#{method_name})
|
||||
undef :#{method_name}
|
||||
end
|
||||
|
|
|
@ -105,7 +105,7 @@ module ActiveModel
|
|||
end
|
||||
|
||||
def _define_before_model_callback(klass, callback) #:nodoc:
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1
|
||||
def self.before_#{callback}(*args, &block)
|
||||
set_callback(:#{callback}, :before, *args, &block)
|
||||
end
|
||||
|
@ -113,7 +113,7 @@ module ActiveModel
|
|||
end
|
||||
|
||||
def _define_around_model_callback(klass, callback) #:nodoc:
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1
|
||||
def self.around_#{callback}(*args, &block)
|
||||
set_callback(:#{callback}, :around, *args, &block)
|
||||
end
|
||||
|
@ -121,7 +121,7 @@ module ActiveModel
|
|||
end
|
||||
|
||||
def _define_after_model_callback(klass, callback) #:nodoc:
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__
|
||||
klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1
|
||||
def self.after_#{callback}(*args, &block)
|
||||
options = args.extract_options!
|
||||
options[:prepend] = true
|
||||
|
|
|
@ -17,7 +17,7 @@ module ActiveRecord
|
|||
# This enhanced read method automatically converts the UTC time stored in the database to the time zone stored in Time.zone.
|
||||
def define_method_attribute(attr_name)
|
||||
if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
|
||||
method_body = <<-EOV
|
||||
method_body, line = <<-EOV, __LINE__ + 1
|
||||
def #{attr_name}(reload = false)
|
||||
cached = @attributes_cache['#{attr_name}']
|
||||
return cached if cached && !reload
|
||||
|
@ -25,7 +25,7 @@ module ActiveRecord
|
|||
@attributes_cache['#{attr_name}'] = time.acts_like?(:time) ? time.in_time_zone : time
|
||||
end
|
||||
EOV
|
||||
generated_attribute_methods.module_eval(method_body, __FILE__, __LINE__)
|
||||
generated_attribute_methods.module_eval(method_body, __FILE__, line)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module ActiveRecord
|
|||
# This enhanced write method will automatically convert the time passed to it to the zone stored in Time.zone.
|
||||
def define_method_attribute=(attr_name)
|
||||
if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
|
||||
method_body = <<-EOV
|
||||
method_body, line = <<-EOV, __LINE__ + 1
|
||||
def #{attr_name}=(time)
|
||||
unless time.acts_like?(:time)
|
||||
time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time
|
||||
|
@ -44,7 +44,7 @@ module ActiveRecord
|
|||
write_attribute(:#{attr_name}, time)
|
||||
end
|
||||
EOV
|
||||
generated_attribute_methods.module_eval(method_body, __FILE__, __LINE__)
|
||||
generated_attribute_methods.module_eval(method_body, __FILE__, line)
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
|
@ -1134,7 +1134,7 @@ module ActiveRecord #:nodoc:
|
|||
attribute_names = match.attribute_names
|
||||
super unless all_attributes_exists?(attribute_names)
|
||||
if match.scope?
|
||||
self.class_eval %{
|
||||
self.class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def self.#{method_id}(*args) # def self.scoped_by_user_name_and_password(*args)
|
||||
options = args.extract_options! # options = args.extract_options!
|
||||
attributes = construct_attributes_from_arguments( # attributes = construct_attributes_from_arguments(
|
||||
|
@ -1143,7 +1143,7 @@ module ActiveRecord #:nodoc:
|
|||
#
|
||||
scoped(:conditions => attributes) # scoped(:conditions => attributes)
|
||||
end # end
|
||||
}, __FILE__, __LINE__
|
||||
METHOD
|
||||
send(method_id, *arguments)
|
||||
end
|
||||
else
|
||||
|
@ -1314,9 +1314,9 @@ module ActiveRecord #:nodoc:
|
|||
modularized_name = type_name_with_module(type_name)
|
||||
silence_warnings do
|
||||
begin
|
||||
class_eval(modularized_name, __FILE__, __LINE__)
|
||||
class_eval(modularized_name, __FILE__)
|
||||
rescue NameError
|
||||
class_eval(type_name, __FILE__, __LINE__)
|
||||
class_eval(type_name, __FILE__)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module ActiveRecord
|
|||
|
||||
def dirties_query_cache(base, *method_names)
|
||||
method_names.each do |method_name|
|
||||
base.class_eval <<-end_code, __FILE__, __LINE__
|
||||
base.class_eval <<-end_code, __FILE__, __LINE__ + 1
|
||||
def #{method_name}_with_query_dirty(*args) # def update_with_query_dirty(*args)
|
||||
clear_query_cache if @query_cache_enabled # clear_query_cache if @query_cache_enabled
|
||||
#{method_name}_without_query_dirty(*args) # update_without_query_dirty(*args)
|
||||
|
|
|
@ -588,11 +588,11 @@ module ActiveResource
|
|||
@prefix_parameters = nil
|
||||
|
||||
# Redefine the new methods.
|
||||
code = <<-end_code
|
||||
code, line = <<-end_code, __LINE__ + 1
|
||||
def prefix_source() "#{value}" end
|
||||
def prefix(options={}) "#{prefix_call}" end
|
||||
end_code
|
||||
silence_warnings { instance_eval code, __FILE__, __LINE__ }
|
||||
silence_warnings { instance_eval code, __FILE__, line }
|
||||
rescue
|
||||
logger.error "Couldn't set prefix: #{$!}\n #{code}" if logger
|
||||
raise
|
||||
|
|
|
@ -57,7 +57,7 @@ module ActiveResource
|
|||
# def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
|
||||
# @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
|
||||
# end
|
||||
module_eval <<-EOE, __FILE__, __LINE__
|
||||
module_eval <<-EOE, __FILE__, __LINE__ + 1
|
||||
def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {})
|
||||
@responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)]
|
||||
end
|
||||
|
@ -125,7 +125,7 @@ module ActiveResource
|
|||
# self.class.requests << request
|
||||
# self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}"))
|
||||
# end
|
||||
module_eval <<-EOE, __FILE__, __LINE__
|
||||
module_eval <<-EOE, __FILE__, __LINE__ + 1
|
||||
def #{method}(path, #{'body, ' if has_body}headers)
|
||||
request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers)
|
||||
self.class.requests << request
|
||||
|
|
|
@ -18,8 +18,8 @@ module ActiveSupport
|
|||
def middleware
|
||||
@middleware ||= begin
|
||||
klass = Class.new
|
||||
klass.class_eval(<<-EOS, __FILE__, __LINE__)
|
||||
def initialize(app)
|
||||
klass.class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
||||
def initialize(app
|
||||
@app = app
|
||||
end
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ module ActiveSupport
|
|||
send("_update_#{symbol}_superclass_callbacks")
|
||||
body = send("_#{symbol}_callbacks").compile(nil)
|
||||
|
||||
body, line = <<-RUBY_EVAL, __LINE__
|
||||
body, line = <<-RUBY_EVAL, __LINE__ + 1
|
||||
def _run_#{symbol}_callbacks(key = nil, &blk)
|
||||
if self.class.send("_update_#{symbol}_superclass_callbacks")
|
||||
self.class.__define_runner(#{symbol.inspect})
|
||||
|
|
|
@ -61,7 +61,7 @@ class Module
|
|||
# e.subject = "Megastars"
|
||||
# e.title # => "Megastars"
|
||||
def alias_attribute(new_name, old_name)
|
||||
module_eval <<-STR, __FILE__, __LINE__+1
|
||||
module_eval <<-STR, __FILE__, __LINE__ + 1
|
||||
def #{new_name}; self.#{old_name}; end # def subject; self.title; end
|
||||
def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end
|
||||
def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end
|
||||
|
|
|
@ -21,7 +21,7 @@ class Module
|
|||
def attr_accessor_with_default(sym, default = nil, &block)
|
||||
raise 'Default value or block required' unless !default.nil? || block
|
||||
define_method(sym, block_given? ? block : Proc.new { default })
|
||||
module_eval(<<-EVAL, __FILE__, __LINE__)
|
||||
module_eval(<<-EVAL, __FILE__, __LINE__ + 1)
|
||||
def #{sym}=(value) # def age=(value)
|
||||
class << self; attr_reader :#{sym} end # class << self; attr_reader :age end
|
||||
@#{sym} = value # @age = value
|
||||
|
|
|
@ -28,7 +28,7 @@ class Module
|
|||
raise ArgumentError, "#{method} is already synchronized. Double synchronization is not currently supported."
|
||||
end
|
||||
|
||||
module_eval(<<-EOS, __FILE__, __LINE__)
|
||||
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
||||
def #{aliased_method}_with_synchronization#{punctuation}(*args, &block) # def expire_with_synchronization(*args, &block)
|
||||
#{with}.synchronize do # @@lock.synchronize do
|
||||
#{aliased_method}_without_synchronization#{punctuation}(*args, &block) # expire_without_synchronization(*args, &block)
|
||||
|
|
Loading…
Reference in a new issue