Class: GrapeSwagger::Markdown

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-swagger/markdown.rb,
lib/grape-swagger/markdown/kramdown_adapter.rb,
lib/grape-swagger/markdown/redcarpet_adapter.rb

Defined Under Namespace

Classes: KramdownAdapter, RedcarpetAdapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter) ⇒ Markdown

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.


10
11
12
13
14
# File 'lib/grape-swagger/markdown.rb', line 10

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

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter


3
4
5
# File 'lib/grape-swagger/markdown.rb', line 3

def adapter
  @adapter
end

Instance Method Details

#as_markdown(text) ⇒ Object

Calls markdown to the configured adapter.


19
20
21
# File 'lib/grape-swagger/markdown.rb', line 19

def as_markdown(text)
  @adapter.markdown(text)
end