# Class: YARD::Server::Commands::LibraryCommand Abstract

Inherits:
  Base
  - Object
  - Base
  - YARD::Server::Commands::LibraryCommand
  show all

Defined in:
  lib/yard/server/commands/library_command.rb

## Overview

This class is abstract.

This is the base command for all commands that deal directly with libraries. Some commands do not, but most (like DisplayObjectCommand) do. If your command deals with libraries directly, subclass this class instead. See Base for notes on how to subclass a command.

Since:

- 0.6.0

## Direct Known Subclasses

DisplayFileCommand, DisplayObjectCommand, ListCommand, SearchCommand, StaticFileCommand

## Instance Attribute Summary collapse

- #incremental ⇒ Boolean

  Whether to reparse data.

- #library ⇒ LibraryVersion

  The object containing library information.

- #options ⇒ LibraryOptions

  Default options for the library.

- #serializer ⇒ Serializers::Base

  The serializer used to perform file linking.

- #single_library ⇒ Boolean

  Whether router should route for multiple libraries.

- #use_fork ⇒ Boolean

  Whether or not this adapter calls `fork` when serving library requests.

## Instance Method Summary collapse

- #call(request) ⇒ Object
- #initialize(opts = {}) ⇒ LibraryCommand constructor

  A new instance of LibraryCommand.

## Constructor Details

### #initialize(opts = {}) ⇒ `LibraryCommand`

Returns a new instance of LibraryCommand.

Since:

- 0.6.0

    63
    64
    65
    66

    # File 'lib/yard/server/commands/library_command.rb', line 63

    def initialize(opts = {})
      super
      self.serializer = DocServerSerializer.new
    end

## Instance Attribute Details

### #incremental ⇒ `Boolean`

Returns whether to reparse data.

Returns:

- (`Boolean`) —

  whether to reparse data

Since:

- 0.6.0

    53
    54
    55

    # File 'lib/yard/server/commands/library_command.rb', line 53

    def incremental
      @incremental
    end

### #library ⇒ `LibraryVersion`

Returns the object containing library information.

Returns:

- (`LibraryVersion`) —

  the object containing library information

Since:

- 0.6.0

    41
    42
    43

    # File 'lib/yard/server/commands/library_command.rb', line 41

    def library
      @library
    end

### #options ⇒ `LibraryOptions`

Returns default options for the library.

Returns:

- (`LibraryOptions`) —

  default options for the library

Since:

- 0.6.0

    44
    45
    46

    # File 'lib/yard/server/commands/library_command.rb', line 44

    def options
      @options
    end

### #serializer ⇒ `Serializers::Base`

Returns the serializer used to perform file linking.

Returns:

- (`Serializers::Base`) —

  the serializer used to perform file linking

Since:

- 0.6.0

    47
    48
    49

    # File 'lib/yard/server/commands/library_command.rb', line 47

    def serializer
      @serializer
    end

### #single_library ⇒ `Boolean`

Returns whether router should route for multiple libraries.

Returns:

- (`Boolean`) —

  whether router should route for multiple libraries

Since:

- 0.6.0

    50
    51
    52

    # File 'lib/yard/server/commands/library_command.rb', line 50

    def single_library
      @single_library
    end

### #use_fork ⇒ `Boolean`

Returns whether or not this adapter calls `fork` when serving library requests. Defaults to false.

Returns:

- (`Boolean`) —

  whether or not this adapter calls `fork` when serving library requests. Defaults to false.

Since:

- 0.6.0

    57
    58
    59

    # File 'lib/yard/server/commands/library_command.rb', line 57

    def use_fork
      @use_fork
    end

## Instance Method Details

### #call(request) ⇒ `Object`

Since:

- 0.6.0

    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79

    # File 'lib/yard/server/commands/library_command.rb', line 68

    def call(request)
      if can_fork?
        call_with_fork(request) { super }
      else
        begin
          save_default_template_info
          call_without_fork(request) { super }
        ensure
          restore_template_info
        end
      end
    end