Sha256: b92f687ed36d3c9feeb9ca62d7ec8d387eb424b8cb5662372701e06542b97f67

Contents?: true

Size: 918 Bytes

Versions: 8

Compression:

Stored size: 918 Bytes

Contents

module Dox
  module Printers
    class ActionPrinter < BasePrinter
      def print(action)
        self.action = action
        @action_hash = find_or_add(find_or_add(spec, action.path.to_s), action.verb.downcase.to_sym)

        add_action
        add_action_params

        print_examples
      end

      private

      attr_accessor :action, :action_hash

      def add_action
        action_hash['summary'] = action.name
        action_hash['tags'] = [action.resource]
        action_hash['description'] = format_desc(action.desc)
      end

      def add_action_params
        return unless action.params.present?

        action_hash['parameters'] = action.params
      end

      def print_examples
        action.examples.each do |example|
          ExampleRequestPrinter.new(action_hash).print(example)
          ExampleResponsePrinter.new(action_hash).print(example)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dox-2.4.0 lib/dox/printers/action_printer.rb
dox-2.3.0 lib/dox/printers/action_printer.rb
dox-2.2.0 lib/dox/printers/action_printer.rb
dox-2.1.0 lib/dox/printers/action_printer.rb
dox-2.0.0 lib/dox/printers/action_printer.rb
dox-2.0.0.beta3 lib/dox/printers/action_printer.rb
dox-2.0.0.beta2 lib/dox/printers/action_printer.rb
dox-2.0.0.beta1 lib/dox/printers/action_printer.rb