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) ⇒ ComponentDocs
constructor
A new instance of ComponentDocs.
Constructor Details
#initialize(gem_components: false, limit_to: false) ⇒ ComponentDocs
Returns a new instance of ComponentDocs.
4 5 6 7 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 4 def initialize(gem_components: false, limit_to: false) @limit_to = limit_to @documentation_directory = gem_components ? gem_documentation_directory : app_documentation_directory end |
Instance Method Details
#all ⇒ Object
14 15 16 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 14 def all fetch_component_doc_files.map { |component| build(component) }.sort_by(&:name) end |
#get(id) ⇒ Object
9 10 11 12 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 9 def get(id) component = fetch_component_doc(id) build(component) end |
#get_component_docs ⇒ Object
18 19 20 |
# File 'app/models/govuk_publishing_components/component_docs.rb', line 18 def get_component_docs fetch_component_doc_files.map { |component| build(component) if component_in_use?(component[:id]) }.compact.sort_by(&:name) end |