Class: SparkComponents::Component

Inherits:
Element
  • Object
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

Constructor Details

This class inherits a constructor from SparkComponents::Element

Class Method Details

.class_nameObject

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_nameObject



9
10
11
# File 'lib/spark_components/component.rb', line 9

def self.component_name
  class_name.chomp("Component").demodulize.underscore
end

.component_pathObject



13
14
15
# File 'lib/spark_components/component.rb', line 13

def self.component_path
  class_name.chomp("Component").underscore
end

.model_nameObject



5
6
7
# File 'lib/spark_components/component.rb', line 5

def self.model_name
  ActiveModel::Name.new(SparkComponents::Component)
end

Instance Method Details

#_nameObject



27
28
29
# File 'lib/spark_components/component.rb', line 27

def _name
  super || self.class.component_name
end

#renderObject



23
24
25
# File 'lib/spark_components/component.rb', line 23

def render
  render_partial to_partial_path
end

#to_partial_pathObject



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