Sha256: bcf7a515319bcb8b999232fb37cbc5da4ce7b67279f0d1bd5008cc36a57b5470
Contents?: true
Size: 1.25 KB
Versions: 6
Compression:
Stored size: 1.25 KB
Contents
class Gon module Helpers def self.included base base.send(:include, InstanceMethods) end module InstanceMethods def include_gon(options = {}) if variables_for_request_present? Gon::Base.render_data(options) elsif Gon.global.all_variables.present? Gon.clear Gon::Base.render_data(options) elsif options[:init].present? Gon.clear if Gon.all_variables.present? Gon::Base.render_data(options) else "" end end private def variables_for_request_present? Gon::Request.env && Gon::Request.id == request.object_id && Gon.all_variables.present? end end end module GonHelpers def self.included base base.send(:include, InstanceMethods) end module InstanceMethods def gon if wrong_gon_request? Gon::Request.id = request.object_id Gon::Request.env = request.env end Gon end private def wrong_gon_request? Gon::Request.env.blank? || Gon::Request.id != request.object_id end end end end ActionView::Base.send :include, Gon::Helpers ActionController::Base.send :include, Gon::GonHelpers
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
gon-4.1.1 | lib/gon/helpers.rb |
gon-4.1.0 | lib/gon/helpers.rb |
gon-4.0.3 | lib/gon/helpers.rb |
gon-4.0.2 | lib/gon/helpers.rb |
gon-4.0.1 | lib/gon/helpers.rb |
gon-4.0.0 | lib/gon/helpers.rb |