Skip to content
Browse files

fix stack trace lines on class_eval

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 8b2266a commit 13e00ce6064fd1ce143071e3531e65f64047b013 @spastorino spastorino committed with josevalim Apr 9, 2010
View
2 actionpack/lib/action_controller/polymorphic_routes.rb
@@ -120,7 +120,7 @@ def polymorphic_path(record_or_hash_or_array, options = {})
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,
View
4 actionpack/lib/action_view/helpers/form_helper.rb
@@ -1105,7 +1105,7 @@ def initialize(object_name, object, template, options, proc)
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 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
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)
View
4 actionpack/test/template/form_helper_test.rb
@@ -1314,12 +1314,12 @@ def test_form_for_and_fields_for_with_object
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
View
4 activemodel/lib/active_model/attribute_methods.rb
@@ -221,7 +221,7 @@ def attribute_method_affix(*affixes)
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 @@ def define_attribute_methods(attr_names)
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
View
6 activemodel/lib/active_model/callbacks.rb
@@ -105,23 +105,23 @@ def define_model_callbacks(*callbacks)
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
CALLBACK
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
CALLBACK
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
View
8 activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
@@ -17,15 +17,15 @@ module ClassMethods
# 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
time = read_attribute('#{attr_name}')
@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 @@ def #{attr_name}(reload = false)
# 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 @@ def #{attr_name}=(time)
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
View
8 activerecord/lib/active_record/base.rb
@@ -1134,7 +1134,7 @@ def method_missing(method_id, *arguments, &block)
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 @@ def self.#{method_id}(*args) # def self.scoped_by_user_na
#
scoped(:conditions => attributes) # scoped(:conditions => attributes)
end # end
- }, __FILE__, __LINE__
+ METHOD
send(method_id, *arguments)
end
else
@@ -1314,9 +1314,9 @@ def compute_type(type_name)
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
View
2 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
@@ -15,7 +15,7 @@ def included(base)
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)
View
4 activeresource/lib/active_resource/base.rb
@@ -588,11 +588,11 @@ def prefix=(value = '/')
@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
View
4 activeresource/lib/active_resource/http_mock.rb
@@ -57,7 +57,7 @@ def initialize(responses)
# 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 @@ def reset!
# 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
View
4 activesupport/lib/active_support/cache/strategy/local_cache.rb
@@ -18,8 +18,8 @@ def with_local_cache
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
View
2 activesupport/lib/active_support/callbacks.rb
@@ -387,7 +387,7 @@ def __define_runner(symbol) #:nodoc:
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})
View
2 activesupport/lib/active_support/core_ext/module/aliasing.rb
@@ -61,7 +61,7 @@ def alias_method_chain(target, feature)
# 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
View
2 activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
@@ -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
View
2 activesupport/lib/active_support/core_ext/module/synchronization.rb
@@ -28,7 +28,7 @@ def synchronize(*methods)
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)

0 comments on commit 13e00ce

Please sign in to comment.
Something went wrong with that request. Please try again.