Class: DocumentationConstraint
- Inherits:
-
Object
- Object
- DocumentationConstraint
- Defined in:
- lib/nexmo_developer/app/constraints/documentation_constraint.rb
Class Method Summary collapse
- .config ⇒ Object
- .documentation ⇒ Object
- .product_with_parent ⇒ Object
- .product_with_parent_list ⇒ Object
- .products_for_routes ⇒ Object
Class Method Details
.config ⇒ Object
20 21 22 23 24 |
# 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 ⇒ Object
2 3 4 |
# 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 ⇒ Object
10 11 12 |
# 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 ⇒ Object
14 15 16 17 18 |
# 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 ⇒ Object
6 7 8 |
# File 'lib/nexmo_developer/app/constraints/documentation_constraint.rb', line 6 def self.products_for_routes product_with_parent_list end |