module Hypermicrodata::Rails::HtmlBasedJsonRenderer
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/hypermicrodata/rails/html_based_json_renderer.rb, line 4 def initialize super @_render_based_html_options = {} end
Public Instance Methods
default_render(*args)
click to toggle source
# File lib/hypermicrodata/rails/html_based_json_renderer.rb, line 30 def default_render(*args) render_based_html(*args) end
render_based_html(*args)
click to toggle source
# File lib/hypermicrodata/rails/html_based_json_renderer.rb, line 19 def render_based_html(*args) lookup_context.formats.first if m = lookup_context.formats.first.to_s.match(/json$/) json_format = m.pre_match.to_sym json = Hypermicrodata::Extract.new(render_to_string(formats: :html), @_render_based_html_options).to_json(json_format) render(json: json) else render(*args) end end
set_location(location)
click to toggle source
# File lib/hypermicrodata/rails/html_based_json_renderer.rb, line 9 def set_location(location) location_url = url_for(location) @_render_based_html_options[:location] = location_url response.headers['Content-Location'] = location_url end
set_profile_path(path)
click to toggle source
# File lib/hypermicrodata/rails/html_based_json_renderer.rb, line 15 def set_profile_path(path) @_render_based_html_options[:profile_path] = view_context.path_to_asset(path) end