Commit a39c63dbebd0dad7bf6aa6cf03d8055ca19edc2e
1 parent
8596ca29
Exists in
master
and in
27 other branches
Replace instance_eval by instance_exec to avoid api break
http://makandracards.com/makandra/14725-instance_eval-behaves-different-in-ruby-1-8-and-ruby-1-9-use-instance_exec-instead
Showing
15 changed files
with
20 additions
and
20 deletions
Show diff stats
app/helpers/application_helper.rb
| @@ -571,7 +571,7 @@ module ApplicationHelper | @@ -571,7 +571,7 @@ module ApplicationHelper | ||
| 571 | # #profile_image) and its name below it. | 571 | # #profile_image) and its name below it. |
| 572 | def profile_image_link( profile, size=:portrait, tag='li', extra_info = nil ) | 572 | def profile_image_link( profile, size=:portrait, tag='li', extra_info = nil ) |
| 573 | if content = @plugins.dispatch_first(:profile_image_link, profile, size, tag, extra_info) | 573 | if content = @plugins.dispatch_first(:profile_image_link, profile, size, tag, extra_info) |
| 574 | - return instance_eval(&content) | 574 | + return instance_exec(&content) |
| 575 | end | 575 | end |
| 576 | name = profile.short_name | 576 | name = profile.short_name |
| 577 | if profile.person? | 577 | if profile.person? |
| @@ -928,7 +928,7 @@ module ApplicationHelper | @@ -928,7 +928,7 @@ module ApplicationHelper | ||
| 928 | def article_to_html(article, options = {}) | 928 | def article_to_html(article, options = {}) |
| 929 | options.merge!(:page => params[:npage]) | 929 | options.merge!(:page => params[:npage]) |
| 930 | content = article.to_html(options) | 930 | content = article.to_html(options) |
| 931 | - content = content.kind_of?(Proc) ? self.instance_eval(&content).html_safe : content.html_safe | 931 | + content = content.kind_of?(Proc) ? self.instance_exec(&content).html_safe : content.html_safe |
| 932 | filter_html(content, article) | 932 | filter_html(content, article) |
| 933 | end | 933 | end |
| 934 | 934 | ||
| @@ -1384,7 +1384,7 @@ module ApplicationHelper | @@ -1384,7 +1384,7 @@ module ApplicationHelper | ||
| 1384 | doc.search('.macro').each do |macro| | 1384 | doc.search('.macro').each do |macro| |
| 1385 | macro_name = macro['data-macro'] | 1385 | macro_name = macro['data-macro'] |
| 1386 | result = @plugins.parse_macro(macro_name, macro, source) | 1386 | result = @plugins.parse_macro(macro_name, macro, source) |
| 1387 | - macro.inner_html = result.kind_of?(Proc) ? self.instance_eval(&result) : result | 1387 | + macro.inner_html = result.kind_of?(Proc) ? self.instance_exec(&result) : result |
| 1388 | end | 1388 | end |
| 1389 | doc.html | 1389 | doc.html |
| 1390 | end | 1390 | end |
app/helpers/boxes_helper.rb
| @@ -221,7 +221,7 @@ module BoxesHelper | @@ -221,7 +221,7 @@ module BoxesHelper | ||
| 221 | 221 | ||
| 222 | if block.embedable? | 222 | if block.embedable? |
| 223 | embed_code = block.embed_code | 223 | embed_code = block.embed_code |
| 224 | - embed_code = instance_eval(&embed_code) if embed_code.respond_to?(:call) | 224 | + embed_code = instance_exec(&embed_code) if embed_code.respond_to?(:call) |
| 225 | html = content_tag('div', | 225 | html = content_tag('div', |
| 226 | content_tag('h2', _('Embed block code')) + | 226 | content_tag('h2', _('Embed block code')) + |
| 227 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + | 227 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + |
app/helpers/comment_helper.rb
| @@ -23,7 +23,7 @@ module CommentHelper | @@ -23,7 +23,7 @@ module CommentHelper | ||
| 23 | 23 | ||
| 24 | def comment_extra_contents(comment) | 24 | def comment_extra_contents(comment) |
| 25 | @plugins.dispatch(:comment_extra_contents, comment).collect do |extra_content| | 25 | @plugins.dispatch(:comment_extra_contents, comment).collect do |extra_content| |
| 26 | - extra_content.kind_of?(Proc) ? self.instance_eval(&extra_content) : extra_content | 26 | + extra_content.kind_of?(Proc) ? self.instance_exec(&extra_content) : extra_content |
| 27 | end.join('\n') | 27 | end.join('\n') |
| 28 | end | 28 | end |
| 29 | 29 | ||
| @@ -41,7 +41,7 @@ module CommentHelper | @@ -41,7 +41,7 @@ module CommentHelper | ||
| 41 | def links_for_comment_actions(comment) | 41 | def links_for_comment_actions(comment) |
| 42 | actions = [link_for_report_abuse(comment), link_for_spam(comment), link_for_edit(comment), link_for_remove(comment)] | 42 | actions = [link_for_report_abuse(comment), link_for_spam(comment), link_for_edit(comment), link_for_remove(comment)] |
| 43 | @plugins.dispatch(:comment_actions, comment).collect do |action| | 43 | @plugins.dispatch(:comment_actions, comment).collect do |action| |
| 44 | - actions << (action.kind_of?(Proc) ? self.instance_eval(&action) : action) | 44 | + actions << (action.kind_of?(Proc) ? self.instance_exec(&action) : action) |
| 45 | end | 45 | end |
| 46 | actions.flatten.compact | 46 | actions.flatten.compact |
| 47 | end | 47 | end |
app/mailers/task_mailer.rb
| @@ -45,7 +45,7 @@ class TaskMailer < ActionMailer::Base | @@ -45,7 +45,7 @@ class TaskMailer < ActionMailer::Base | ||
| 45 | 45 | ||
| 46 | def extract_message(message) | 46 | def extract_message(message) |
| 47 | if message.kind_of?(Proc) | 47 | if message.kind_of?(Proc) |
| 48 | - self.instance_eval(&message) | 48 | + self.instance_exec(&message) |
| 49 | else | 49 | else |
| 50 | message.to_s | 50 | message.to_s |
| 51 | end | 51 | end |
app/views/comment/_comment.html.erb
| @@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
| 43 | <p/> | 43 | <p/> |
| 44 | <%= txt2html comment.body %> | 44 | <%= txt2html comment.body %> |
| 45 | </div> | 45 | </div> |
| 46 | - <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_eval(&content) }.join("") %> | 46 | + <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_exec(&content) }.join("") %> |
| 47 | </div> | 47 | </div> |
| 48 | 48 | ||
| 49 | <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>"> | 49 | <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>"> |
app/views/comment/_comment_form.html.erb
| @@ -79,7 +79,7 @@ function check_captcha(button, confirm_action) { | @@ -79,7 +79,7 @@ function check_captcha(button, confirm_action) { | ||
| 79 | <%= hidden_field_tag(:view, params[:view])%> | 79 | <%= hidden_field_tag(:view, params[:view])%> |
| 80 | <%= f.hidden_field(:reply_of_id) %> | 80 | <%= f.hidden_field(:reply_of_id) %> |
| 81 | 81 | ||
| 82 | - <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns).collect { |content| instance_eval(&content) }.join("") %> | 82 | + <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns).collect { |content| instance_exec(&content) }.join("") %> |
| 83 | 83 | ||
| 84 | <% button_bar do %> | 84 | <% button_bar do %> |
| 85 | <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %> | 85 | <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %> |
app/views/content_viewer/_article_toolbar.html.erb
| @@ -60,7 +60,7 @@ | @@ -60,7 +60,7 @@ | ||
| 60 | <div class="blog-cover"><%= image_tag(@page.image.public_filename())%></div> | 60 | <div class="blog-cover"><%= image_tag(@page.image.public_filename())%></div> |
| 61 | <% end %> | 61 | <% end %> |
| 62 | <%= link_to(image_tag('icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> | 62 | <%= link_to(image_tag('icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> |
| 63 | - <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_eval(&content) }.join("") %> | 63 | + <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> |
| 64 | <%= article_title(@page, :no_link => true) %> | 64 | <%= article_title(@page, :no_link => true) %> |
| 65 | <%= article_translations(@page) %> | 65 | <%= article_translations(@page) %> |
| 66 | </div> | 66 | </div> |
app/views/content_viewer/view_page.html.erb
| @@ -70,7 +70,7 @@ | @@ -70,7 +70,7 @@ | ||
| 70 | 70 | ||
| 71 | <%= display_source_info(@page) %> | 71 | <%= display_source_info(@page) %> |
| 72 | 72 | ||
| 73 | -<%= @plugins.dispatch(:article_extra_contents, @page).collect { |content| instance_eval(&content) }.join("") %> | 73 | +<%= @plugins.dispatch(:article_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> |
| 74 | 74 | ||
| 75 | <div class="comments" id="comments_list"> | 75 | <div class="comments" id="comments_list"> |
| 76 | 76 |
app/views/layouts/_user.html.erb
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | <span class='not-logged-in' style='display: none'> | 5 | <span class='not-logged-in' style='display: none'> |
| 6 | 6 | ||
| 7 | <%= _("<span class='login'>%s</span>") % thickbox_inline_popup_link('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, 'inlineLoginBox', :id => 'link_login') %> | 7 | <%= _("<span class='login'>%s</span>") % thickbox_inline_popup_link('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, 'inlineLoginBox', :id => 'link_login') %> |
| 8 | - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_eval(&content) }.join("") %> | 8 | + <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") %> |
| 9 | 9 | ||
| 10 | <div id='inlineLoginBox' style='display: none;'> | 10 | <div id='inlineLoginBox' style='display: none;'> |
| 11 | <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> | 11 | <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> |
app/views/layouts/application-ng.html.erb
| @@ -35,7 +35,7 @@ | @@ -35,7 +35,7 @@ | ||
| 35 | <%= yield :head %> | 35 | <%= yield :head %> |
| 36 | <%= | 36 | <%= |
| 37 | @plugins.dispatch(:head_ending).map do |content| | 37 | @plugins.dispatch(:head_ending).map do |content| |
| 38 | - if content.respond_to?(:call) then instance_eval(&content).html_safe else content.html_safe end | 38 | + if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end |
| 39 | end.join("\n") | 39 | end.join("\n") |
| 40 | %> | 40 | %> |
| 41 | 41 | ||
| @@ -50,7 +50,7 @@ | @@ -50,7 +50,7 @@ | ||
| 50 | 50 | ||
| 51 | <%= | 51 | <%= |
| 52 | @plugins.dispatch(:body_beginning).map do |content| | 52 | @plugins.dispatch(:body_beginning).map do |content| |
| 53 | - if content.respond_to?(:call) then instance_eval(&content).html_safe else content.html_safe end | 53 | + if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end |
| 54 | end.join("\n") | 54 | end.join("\n") |
| 55 | %> | 55 | %> |
| 56 | 56 |
app/views/profile/index.html.erb
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | <table class='profile'> | 19 | <table class='profile'> |
| 20 | <tr> | 20 | <tr> |
| 21 | <td colspan='2'> | 21 | <td colspan='2'> |
| 22 | - <% plugins_tabs = @plugins.dispatch(:profile_tabs).map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_eval(&tab[:content]), :start => tab[:title]} }%> | 22 | + <% plugins_tabs = @plugins.dispatch(:profile_tabs).map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_exec(&tab[:content]), :start => tab[:title]} }%> |
| 23 | 23 | ||
| 24 | <% tabs = plugins_tabs.select { |tab| tab[:start] } %> | 24 | <% tabs = plugins_tabs.select { |tab| tab[:start] } %> |
| 25 | 25 |
app/views/profile_editor/_organization.html.erb
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | 4 | ||
| 5 | <%= required f.text_field(:name) %> | 5 | <%= required f.text_field(:name) %> |
| 6 | 6 | ||
| 7 | - <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %> | 7 | + <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %> |
| 8 | 8 | ||
| 9 | <% if @environment.enabled?('enable_organization_url_change') %> | 9 | <% if @environment.enabled?('enable_organization_url_change') %> |
| 10 | <script type="text/javascript"> | 10 | <script type="text/javascript"> |
app/views/profile_editor/_person.html.erb
| @@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
| 16 | </div> | 16 | </div> |
| 17 | </div> | 17 | </div> |
| 18 | 18 | ||
| 19 | - <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_eval(&content) }.join("") %> | 19 | + <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %> |
| 20 | 20 | ||
| 21 | <%= render :partial => 'person_form', :locals => {:f => f} %> | 21 | <%= render :partial => 'person_form', :locals => {:f => f} %> |
| 22 | 22 |
app/views/profile_editor/edit.html.erb
| @@ -53,7 +53,7 @@ | @@ -53,7 +53,7 @@ | ||
| 53 | 53 | ||
| 54 | <%= | 54 | <%= |
| 55 | @plugins.dispatch(:profile_editor_extras).map do |content| | 55 | @plugins.dispatch(:profile_editor_extras).map do |content| |
| 56 | - if content.respond_to?(:call) then instance_eval(&content).html_safe else content.html_safe end | 56 | + if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end |
| 57 | end.join("\n") | 57 | end.join("\n") |
| 58 | %> | 58 | %> |
| 59 | 59 |
app/views/search/_full_product.html.erb
| 1 | -<% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_eval(&content) } %> | 1 | +<% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_exec(&content) } %> |
| 2 | <% extra_properties = @plugins.dispatch(:asset_product_properties, product)%> | 2 | <% extra_properties = @plugins.dispatch(:asset_product_properties, product)%> |
| 3 | 3 | ||
| 4 | <li class="search-product-item <%= 'highlighted' if product.highlighted? %>"> | 4 | <li class="search-product-item <%= 'highlighted' if product.highlighted? %>"> |
| @@ -79,7 +79,7 @@ | @@ -79,7 +79,7 @@ | ||
| 79 | 79 | ||
| 80 | <%= extra_content.join('\n') %> | 80 | <%= extra_content.join('\n') %> |
| 81 | <% extra_properties.each do |property| %> | 81 | <% extra_properties.each do |property| %> |
| 82 | - <div><%= property[:name] + ': ' + instance_eval(&property[:content]) %></div> | 82 | + <div><%= property[:name] + ': ' + instance_exec(&property[:content]) %></div> |
| 83 | <% end %> | 83 | <% end %> |
| 84 | 84 | ||
| 85 | </li> | 85 | </li> |