Class: Lookbook::Component
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Entity
#<=>, #id, #label, #lookup_path, #type, #url_path
Constructor Details
#initialize(component_class) ⇒ Component
Returns a new instance of Component.
7
8
9
10
11
12
|
# File 'lib/lookbook/entities/component.rb', line 7
def initialize(component_class)
@component_class = component_class
@file_path = "#{Engine.component_paths.first}/#{name.underscore}.rb"
@base_directories = Engine.component_paths
@lookup_path = PathUtils.to_lookup_path(relative_file_path)
end
|
Instance Attribute Details
#component_class ⇒ Object
Returns the value of attribute component_class.
5
6
7
|
# File 'lib/lookbook/entities/component.rb', line 5
def component_class
@component_class
end
|
Instance Method Details
#inline? ⇒ Boolean
22
23
24
|
# File 'lib/lookbook/entities/component.rb', line 22
def inline?
template_file_path.present?
end
|
#name ⇒ Object
14
15
16
|
# File 'lib/lookbook/entities/component.rb', line 14
def name
component_class.name
end
|
#template_file_path ⇒ Object
18
19
20
|
# File 'lib/lookbook/entities/component.rb', line 18
def template_file_path
Dir.glob("#{directory_path}/#{file_name(true)}.*.erb").first
end
|
#template_path ⇒ Object
26
27
28
29
|
# File 'lib/lookbook/entities/component.rb', line 26
def template_path
Lookbook.logger.warn "The `template_path` method has been deprecated - use `template_file_path` instead. `template_file_path` will be removed in v2.0"
template_file_path
end
|