Class: GovukPublishingComponents::ComponentDocs
- Inherits:
-
Object
- Object
- GovukPublishingComponents::ComponentDocs
- Defined in:
- app/models/govuk_publishing_components/component_docs.rb
Instance Method Summary collapse
- #all ⇒ Object
- #get(id) ⇒ Object
- #get_component_docs ⇒ Object
-
#initialize(gem_components: false, limit_to: false, flexible_sections: false) ⇒ ComponentDocs
constructor
A new instance of ComponentDocs.
Constructor Details
#initialize(gem_components: false, limit_to: false, flexible_sections: false) ⇒ ComponentDocs
Returns a new instance of ComponentDocs.
4 5 6 7 8 9 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 4 def initialize(gem_components: false, limit_to: false, flexible_sections: false) @limit_to = limit_to @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory @documentation_directory = flexible_sections_documentation_directory if flexible_sections @type = flexible_sections ? "flexible section" : "component" end |
Instance Method Details
#all ⇒ Object
16 17 18 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 16 def all fetch_component_doc_files.map { |component| build(component) }.sort_by(&:name) end |
#get(id) ⇒ Object
11 12 13 14 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 11 def get(id) component = fetch_component_doc(id) build(component) end |
#get_component_docs ⇒ Object
20 21 22 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 20 def get_component_docs fetch_component_doc_files.map { |component| build(component) if component_in_use?(component[:id]) }.compact.sort_by(&:name) end |