Sha256: 161f35c219fef99a97fcbd13d023e911d2269b1ed148b9a5590d13beef55b08a

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

# encoding: utf-8

module Okei
  module Api
    module V1

      # Responds to client depending on use case results
      class Responder < ::ApplicationController

        # Renders a list of units of measure.
        #
        # Params:
        # +units+:: a list of units found by use case
        #
        def on_success(units)
          @units = units
          render "index"
        end

        # Renders a unit of measure.
        #
        # Params:
        # +unit+:: a unit of measure to be rendered and sent to a client.
        #
        def on_found(unit)
          @unit = unit
          render "show"
        end

        # Renders an error messages.
        #
        # Params:
        # +messages+:: a list of messages (<tt>Hexx::Message</tt> objects)
        #              to be shown to a client.
        #
        def on_not_found(messages)
          @messages = messages
          render "errors", status: 404
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
okei-1.0.0 app/controllers/okei/api/v1/responder.rb
okei-1.0.0.pre.rc app/controllers/okei/api/v1/responder.rb