Class: Redmine::Views::Builders::Json
- Defined in:
- lib/redmine/views/builders/json.rb
Instance Attribute Summary collapse
-
#jsonp ⇒ Object
Returns the value of attribute jsonp.
Instance Method Summary collapse
-
#initialize(request, response) ⇒ Json
constructor
A new instance of Json.
- #output ⇒ Object
Methods inherited from Structure
#array, #encode_value, #method_missing
Constructor Details
#initialize(request, response) ⇒ Json
Returns a new instance of Json.
28 29 30 31 32 33 34 |
# File 'lib/redmine/views/builders/json.rb', line 28 def initialize(request, response) super callback = request.params[:callback] || request.params[:jsonp] if callback && Setting.jsonp_enabled? self.jsonp = callback.to_s.gsub(/[^a-zA-Z0-9_.]/, '') end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Redmine::Views::Builders::Structure
Instance Attribute Details
#jsonp ⇒ Object
Returns the value of attribute jsonp.
26 27 28 |
# File 'lib/redmine/views/builders/json.rb', line 26 def jsonp @jsonp end |
Instance Method Details
#output ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/redmine/views/builders/json.rb', line 36 def output json = @struct.first.to_json if jsonp.present? json = "#{jsonp}(#{json})" @response.content_type = 'application/javascript' end json end |