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
26 27 28 29 30 31 32 |
# File 'lib/redmine/views/builders/json.rb', line 26 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
24 25 26 |
# File 'lib/redmine/views/builders/json.rb', line 24 def jsonp @jsonp end |
Instance Method Details
#output ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/redmine/views/builders/json.rb', line 34 def output json = @struct.first.to_json if jsonp.present? json = "#{jsonp}(#{json})" @response.content_type = 'application/javascript' end json end |