Module: Grape::Formatter::Rabl
- Defined in:
- lib/grape-rabl/formatter.rb
Class Attribute Summary collapse
-
.endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
.env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Class Attribute Details
.endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
9 10 11 |
# File 'lib/grape-rabl/formatter.rb', line 9 def endpoint @endpoint end |
.env ⇒ Object (readonly)
Returns the value of attribute env.
8 9 10 |
# File 'lib/grape-rabl/formatter.rb', line 8 def env @env end |
Class Method Details
.call(object, env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/grape-rabl/formatter.rb', line 11 def call(object, env) @env = env @endpoint = env['api.endpoint'] if rablable? rabl do |template| engine = ::Tilt.new(view_path(template), {format: env['api.format'], view_path: env['api.tilt.root']}) engine.render endpoint, {} end else Grape::Formatter::Json.call object, env end end |