Module: JsonSchemaView::SchemaSet::ConstantSearchHelper
Overview
Add methods to search constants in the directory to SchemaSet.
Defined Under Namespace
Classes: ConstantAutoLoader
Instance Method Summary
collapse
Instance Method Details
#all_constants ⇒ Array<Class, Module>
28
29
30
|
# File 'lib/json_schema_view/schema_set/constant_search_helper.rb', line 28
def all_constants
@all_constants ||= search_constants(path_pattern: "**/*.rb")
end
|
#search_component_classes(path_pattern: nil) ⇒ Array<Class<BaseComponent>>
11
12
13
14
|
# File 'lib/json_schema_view/schema_set/constant_search_helper.rb', line 11
def search_component_classes(path_pattern: nil)
constants = path_pattern ? search_constants(path_pattern) : all_constants
constants.select { |const| const.is_a?(Class) && const < JsonSchemaView::BaseComponent }
end
|
#search_constants(path_pattern: "**/*.rb") ⇒ Array<Class, Module>
17
18
19
20
21
22
23
24
25
|
# File 'lib/json_schema_view/schema_set/constant_search_helper.rb', line 17
def search_constants(path_pattern: "**/*.rb")
loader = ConstantAutoLoader.from_rails_app
root_pathname = Pathname.new(root_path)
Dir.glob(path_pattern, base: root_path).filter_map do |path|
path = root_pathname.join(path)
loader.load_constant_by_path(path)
end
end
|