Module: Grape::Formatter::Rabl

Defined in:
lib/grape-rabl/formatter.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.endpointObject (readonly)

Returns the value of attribute endpoint.



8
9
10
# File 'lib/grape-rabl/formatter.rb', line 8

def endpoint
  @endpoint
end

.envObject (readonly)

Returns the value of attribute env.



7
8
9
# File 'lib/grape-rabl/formatter.rb', line 7

def env
  @env
end

Class Method Details

.call(object, env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/grape-rabl/formatter.rb', line 10

def call(object, env)
  @env = env
  @endpoint = env['api.endpoint']

  if rablable?
    rabl do |template|
      engine = tilt_template(template)
      output = engine.render endpoint, locals
      if layout_template
        layout_template.render(endpoint) { output }
      else
        output
      end
    end
  else
    Grape::Formatter::Json.call object, env
  end
end