Class: SparkComponents::Component
- Inherits:
-
Element
- Object
- Element
- SparkComponents::Component
show all
- Defined in:
- lib/spark_components/component.rb
Instance Attribute Summary
Attributes inherited from Element
#attr, #parents, #yield
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Element
#add_class, add_class, #after_init, #aria_attr, aria_attr, attribute, attributes, base_class, #base_class, #before_render, #blank?, #classnames, data_attr, #data_attr, element, elements, inherited, #initialize, #join_class, #parent, #parent=, #render_block, root_attr, #root_attr, set_attribute, tag_attrs, #tag_attrs, #to_s, validates_choice
Class Method Details
.class_name ⇒ Object
Allow Components to lookup their original classname even if created with Class.new(SomeComponent)
19
20
21
|
# File 'lib/spark_components/component.rb', line 19
def self.class_name
name || superclass.name
end
|
.component_name ⇒ Object
9
10
11
|
# File 'lib/spark_components/component.rb', line 9
def self.component_name
class_name.chomp("Component").demodulize.underscore
end
|
.component_path ⇒ Object
13
14
15
|
# File 'lib/spark_components/component.rb', line 13
def self.component_path
class_name.chomp("Component").underscore
end
|
.model_name ⇒ Object
5
6
7
|
# File 'lib/spark_components/component.rb', line 5
def self.model_name
ActiveModel::Name.new(SparkComponents::Component)
end
|
Instance Method Details
#_name ⇒ Object
27
28
29
|
# File 'lib/spark_components/component.rb', line 27
def _name
super || self.class.component_name
end
|
#render ⇒ Object
23
24
25
|
# File 'lib/spark_components/component.rb', line 23
def render
render_partial to_partial_path
end
|
#to_partial_path ⇒ Object
31
32
33
|
# File 'lib/spark_components/component.rb', line 31
def to_partial_path
[self.class.component_path, self.class.component_name].join("/")
end
|