Class: Lookbook::Component
- Includes:
- Locatable
- Defined in:
- lib/lookbook/entities/component.rb
Instance Attribute Summary collapse
-
#component_class ⇒ Object
readonly
Returns the value of attribute component_class.
Instance Method Summary collapse
-
#initialize(component_class) ⇒ Component
constructor
A new instance of Component.
- #inline? ⇒ Boolean
- #name ⇒ Object
- #template_file_path ⇒ Object
- #template_path ⇒ Object
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 (readonly)
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 |