class DocumentationConstraint

Public Class Methods

config() click to toggle source
# File lib/nexmo_developer/app/constraints/documentation_constraint.rb, line 20
def self.config
  @config ||= YAML.safe_load(
    File.read("#{Rails.configuration.docs_base_path}/config/products.yml")
  )
end
documentation() click to toggle source
# File lib/nexmo_developer/app/constraints/documentation_constraint.rb, line 2
def self.documentation
  Nexmo::Markdown::CodeLanguage.route_constraint.merge(product_with_parent)
end
product_with_parent() click to toggle source
# File lib/nexmo_developer/app/constraints/documentation_constraint.rb, line 10
def self.product_with_parent
  { product: Regexp.new(product_with_parent_list.compact.reverse.join('|')) }
end
product_with_parent_list() click to toggle source
# File lib/nexmo_developer/app/constraints/documentation_constraint.rb, line 14
def self.product_with_parent_list
  raise ArgumentError, "The 'product' key in config/products.yml must be a list with at least one entry." if config.fetch('products', []).size.zero?

  @product_with_parent_list ||= config.fetch('products', []).map { |product| product['path'] }
end
products_for_routes() click to toggle source
# File lib/nexmo_developer/app/constraints/documentation_constraint.rb, line 6
def self.products_for_routes
  product_with_parent_list
end