Class: Styleus::ViewComponent
- Inherits:
-
Base
- Object
- Base
- Styleus::ViewComponent
show all
- Defined in:
- app/models/styleus/view_component.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #to_key, with_attributes
Constructor Details
This class inherits a constructor from Styleus::Base
Class Method Details
.components ⇒ Object
17
18
19
|
# File 'app/models/styleus/view_component.rb', line 17
def components
@components ||= []
end
|
.from_hashes(hashes) ⇒ Object
21
22
23
24
25
|
# File 'app/models/styleus/view_component.rb', line 21
def from_hashes(hashes)
components.clear
hashes.each { |comp_hash| components << new(comp_hash) }
components
end
|
.from_names(section, names) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/models/styleus/view_component.rb', line 27
def from_names(section, names)
components.clear
names.each do |name|
components << new(
headline: name.to_s.humanize,
partial_path: File.join('components', section, "#{name}"))
end
components
end
|
Instance Method Details
#id ⇒ Object
id is used as anchor id in the anchor menu, so it has to be a uid. TODO: make sure the uid-ness :)
8
9
10
|
# File 'app/models/styleus/view_component.rb', line 8
def id
headline.underscore.gsub(/ /, '_')
end
|
#to_s ⇒ Object
12
13
14
|
# File 'app/models/styleus/view_component.rb', line 12
def to_s
headline.humanize.pluralize
end
|