class Grape::Formatter::Builder
Attributes
endpoint[R]
env[R]
object[R]
Public Class Methods
call(object, env)
click to toggle source
# File lib/grape/formatter/builder.rb, line 6 def self.call(object, env) new(object, env).call end
new(object, env)
click to toggle source
# File lib/grape/formatter/builder.rb, line 10 def initialize(object, env) @object, @env = object, env @endpoint = env['api.endpoint'] end
Public Instance Methods
call()
click to toggle source
# File lib/grape/formatter/builder.rb, line 15 def call return Grape::Formatter::Xml.call(object, env) unless template? Grape::Builder::Renderer.new(env['api.tilt.root'], template). render(endpoint, locals) end
Private Instance Methods
locals()
click to toggle source
# File lib/grape/formatter/builder.rb, line 24 def locals env['api.tilt.locals'] || {} end
template()
click to toggle source
# File lib/grape/formatter/builder.rb, line 28 def template env['api.tilt.template'] || endpoint.options.fetch(:route_options, {})[:builder] end
template?()
click to toggle source
# File lib/grape/formatter/builder.rb, line 33 def template? !!template end