Sha256: 1384d43ce076a0eba550eb6bcd360c83a7e1083a25dd2118875bca9ec50da74c

Contents?: true

Size: 936 Bytes

Versions: 4

Compression:

Stored size: 936 Bytes

Contents

module LadyJosephine
  class EditorController < ::ApplicationController

    def ping
      if @resource = find_resource
        result = {ping: {}}

        if @resource.ping(current_user, params[:update] == "force")
          @resource.save
          result[:ping][:state] = "OK"
        else
          result[:ping][:state] = "CONFLICT"
        end

        result[:ping][:ping_date] = @resource.ping_date
        result[:ping][:user_id]   = @resource.ping_user.try :id
        result[:ping][:user_name] = @resource.ping_user.try :name
        render json: result
      end
    end

    def version
      if @resource = find_resource
        render json: @resource
      end
    end

    private

    def find_resource
      if (@resource = params[:resource].capitalize.constantize.where(server_uuid: params[:id]).first)
        @resource
      else
        render nothing: true, status: 404
        nil
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lady_josephine-0.0.4 app/controllers/lady_josephine/editor_controller.rb
lady_josephine-0.0.3 app/controllers/lady_josephine/editor_controller.rb
lady_josephine-0.0.2 app/controllers/lady_josephine/editor_controller.rb
lady_josephine-0.0.1 app/controllers/lady_josephine/editor_controller.rb