{
  "version": "1.4",
  "metadata": {
  },
  "classMap": [
    {
      "name": "app/models",
      "type": "package",
      "children": [
        {
          "name": "ApiKey",
          "type": "class",
          "children": [
            {
              "name": "issue",
              "type": "function",
              "location": "app/models/api_key.rb:28",
              "static": true,
              "source": "    def issue(login, description: nil, encode: true)\n      api_key = DAO::ApiKey.new.tap do |api_key|\n        api_key.login = login\n        api_key.description = description if description.present?\n        api_key.save\n      end\n\n      return encode(api_key) if encode\n\n      api_key\n    end\n"
            },
            {
              "name": "encode",
              "type": "function",
              "location": "app/models/api_key.rb:20",
              "static": true,
              "source": "    def encode(api_key)\n      Base64.urlsafe_encode64([api_key.login, api_key.key].join(SEPARATOR), padding: false)\n    end\n"
            },
            {
              "name": "authenticate",
              "type": "function",
              "location": "app/models/api_key.rb:52",
              "static": true,
              "labels": [
                "provider.authentication"
              ],
              "comment": "# @labels provider.authentication\n",
              "source": "    def authenticate(api_key)\n      login, key = decode(api_key)\n      result = DAO::ApiKey.where(login: login).match(key)\n\n      if result.present?\n        touch(result)\n        User::Show.new(result.user)\n      else\n        nil\n      end\n    end\n"
            },
            {
              "name": "decode",
              "type": "function",
              "location": "app/models/api_key.rb:24",
              "static": true,
              "source": "    def decode(api_key)\n      Base64.urlsafe_decode64(api_key).split(SEPARATOR)\n    end\n"
            },
            {
              "name": "touch",
              "type": "function",
              "location": "app/models/api_key.rb:11",
              "static": true,
              "source": "    def touch(api_key)\n      if api_key.last_used.nil? || api_key.last_used > 15.minutes.ago\n        api_key.last_used = Time.now\n        api_key.save_changes\n      end\n\n      api_key\n    end\n"
            }
          ]
        }
      ]
    },
    {
      "name": "action_pack",
      "type": "package",
      "children": [
        {
          "name": "ActionDispatch",
          "type": "class",
          "children": [
            {
              "name": "Cookies",
              "type": "class",
              "children": [
                {
                  "name": "CookieJar",
                  "type": "class",
                  "children": [
                    {
                      "name": "update",
                      "type": "function",
                      "location": "/Users/kgilpin/tmp/appland/vendor/bundle/ruby/2.6.0/gems/actionpack-5.2.4.2/lib/action_dispatch/middleware/cookies.rb:344",
                      "static": false,
                      "labels": [
                        "provider.http.cookie"
                      ],
                      "source": "      def update(other_hash)\n        @cookies.update other_hash.stringify_keys\n        self\n      end\n"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "app/controllers",
      "type": "package",
      "children": [
        {
          "name": "API",
          "type": "class",
          "children": [
            {
              "name": "APIKeysController",
              "type": "class",
              "children": [
                {
                  "name": "create",
                  "type": "function",
                  "location": "app/controllers/api/api_keys_controller.rb:10",
                  "static": false,
                  "source": "    def create\n      new_key = ApiKey.issue(@current_user.login, description: params[:description])\n      render json: { api_key: new_key }, status: :created\n    end\n"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "json",
      "type": "package",
      "children": [
        {
          "name": "JSON",
          "type": "class",
          "children": [
            {
              "name": "Ext",
              "type": "class",
              "children": [
                {
                  "name": "Generator",
                  "type": "class",
                  "children": [
                    {
                      "name": "State",
                      "type": "class",
                      "children": [
                        {
                          "name": "generate",
                          "type": "function",
                          "location": "JSON::Ext::Generator::State#generate",
                          "static": false,
                          "labels": [
                            "format.json",
                            "provider.serialization"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "Parser",
                  "type": "class",
                  "children": [
                    {
                      "name": "parse",
                      "type": "function",
                      "location": "JSON::Ext::Parser#parse",
                      "static": false,
                      "labels": [
                        "format.json",
                        "provider.serialization"
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "events": [
    {
      "id": 26693,
      "event": "call",
      "thread_id": 70146500788180,
      "http_server_request": {
        "request_method": "POST",
        "path_info": [ "/api/api_keys" ]
      }
    },
    {
      "id": 26718,
      "event": "return",
      "thread_id": 70146500788180,
      "parent_id": 26693,
      "elapsed": 0.048602,
      "http_server_response": {
        "status": 201
      }
    }
  ]
}
