Sha256: 431e68fb74d99496427cf9ca9bf95010a09965d01ca93728f3c8ddebee62a818

Contents?: true

Size: 726 Bytes

Versions: 2

Compression:

Stored size: 726 Bytes

Contents

module GrapeSwagger
  class Markdown
    attr_reader :adapter

    ###
    # Initializes the markdown class with an adapter.
    # The adapter needs to implement the method markdown which will be called by this interface class.
    # The adapters are responsible of loading the required markdown dependencies and throw errors.
    ###
    def initialize(adapter)
      adapter = adapter.new if adapter.is_a?(Class)
      fail(ArgumentError, "The configured markdown adapter should implement the method #{:markdown}") unless adapter.respond_to? :markdown
      @adapter = adapter
    end

    ###
    # Calls markdown to the configured adapter.
    ###
    def as_markdown(text)
      @adapter.markdown(text)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
grape-swagger-0.10.5 lib/grape-swagger/markdown.rb
grape-swagger-0.10.4 lib/grape-swagger/markdown.rb