Sha256: e3274d37d25c9a5a676b53e4026931414a9dc635411683a8b9f252711ca0119d
Contents?: true
Size: 775 Bytes
Versions: 1
Compression:
Stored size: 775 Bytes
Contents
module Grape module Formatter class Jbuilder attr_reader :env, :endpoint, :object def self.call(object, env) new(object, env).call end def initialize(object, env) @object, @env = object, env @endpoint = env['api.endpoint'] end def call return Grape::Formatter::Json.call(object, env) unless template? Grape::Jbuilder::Renderer.new(env['api.tilt.root'], template). render(endpoint, locals) end private def locals env['api.tilt.locals'] || {} end def template env['api.tilt.template'] || endpoint.options.fetch(:route_options, {})[:jbuilder] end def template? !!template end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-jbuilder-0.2.0 | lib/grape/formatter/jbuilder.rb |