Class: Paltrow::Rendering::Rails::JSON

Inherits:
Object
  • Object
show all
Defined in:
lib/paltrow/rendering/rails/json.rb

Instance Method Summary collapse

Instance Method Details

#call(handler:, page:) ⇒ Object



5
6
7
8
9
10
# File 'lib/paltrow/rendering/rails/json.rb', line 5

def call handler:, page:
  page
    .to_monad
    .fmap { |page| handler.render(json: page.locals) }
    .or { |page| handler.render(json: {error: page.message}, status: :unprocessable_entity) }
end