Class: Lookbook::Component

Inherits:
Entity
  • Object
show all
Includes:
Locatable
Defined in:
lib/lookbook/entities/component.rb

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_classObject (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

Returns:

  • (Boolean)


22
23
24
# File 'lib/lookbook/entities/component.rb', line 22

def inline?
  template_file_path.present?
end

#nameObject



14
15
16
# File 'lib/lookbook/entities/component.rb', line 14

def name
  component_class.name
end

#template_file_pathObject



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_pathObject



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