Sha256: 5faabad6c6bd236d5a9006027ae4cc9e162430ecaa9fef47eef353a237e728c7

Contents?: true

Size: 643 Bytes

Versions: 2

Compression:

Stored size: 643 Bytes

Contents

module RailsScript
  module LoaderHelper

    def include_rails_script
      javascript_tag <<-RUBY
window.Utility || (window.Utility = {});
Utility.RailsVars = #{@to_javascript.nil? ? '{}' : @to_javascript.to_json};

(function() {
  window.$this = new (App.#{ controller_path.split(/\/|_/).map(&:capitalize).join('') } || App.Base)();
  if (typeof $this.beforeAction === 'function') {
    $this.beforeAction("#{action_name}");
  }
  if (typeof $this.#{ action_name } === 'function') {
    $this.#{ action_name }();
  }
  if (typeof $this.afterAction === 'function') {
    $this.afterAction("#{action_name}");
  }
})();
RUBY
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_script-0.6.1 lib/rails_script/loader_helper.rb
rails_script-0.6.0 lib/rails_script/loader_helper.rb