Class: ActionView::Helpers::JavaScriptVariableProxy

Inherits:
JavaScriptProxy show all
Defined in:
actionpack/lib/action_view/helpers/prototype_helper.rb

Overview

:nodoc:

Instance Method Summary (collapse)

Methods inherited from JavaScriptProxy

#is_a?

Methods inherited from ActiveSupport::BasicObject

#raise

Constructor Details

- (JavaScriptVariableProxy) initialize(generator, variable)

A new instance of JavaScriptVariableProxy



725
726
727
728
729
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 725

def initialize(generator, variable)
  @variable = ::ActiveSupport::JSON::Variable.new(variable)
  @empty    = true # only record lines if we have to.  gets rid of unnecessary linebreaks
  super(generator)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActionView::Helpers::JavaScriptProxy

Instance Method Details

- (Object) as_json(options = nil)



737
738
739
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 737

def as_json(options = nil)
  @variable
end

- (Boolean) respond_to?

The JSON Encoder calls this to check for the to_json method Since it's a blank slate object, I suppose it responds to anything.

Returns:

  • (Boolean)


733
734
735
# File 'actionpack/lib/action_view/helpers/prototype_helper.rb', line 733

def respond_to?(*)
  true
end