Class: Lite::Component::Base

Inherits:
Element
  • Object
show all
Defined in:
lib/lite/component/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

attribute, attributes, element, elements, #initialize, #to_s

Constructor Details

This class inherits a constructor from Lite::Component::Element

Class Method Details

.component_nameObject



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

def component_name
  component_path.split('/').last
end

.component_pathObject



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

def component_path
  name.chomp('Component').underscore
end

.model_nameObject



17
18
19
# File 'lib/lite/component/base.rb', line 17

def model_name
  ActiveModel::Name.new(Lite::Component::Base)
end

Instance Method Details

#renderObject



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

def render
  @view.render(partial: to_partial_path, object: self)
end

#to_partial_pathObject



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

def to_partial_path
  "components/#{self.class.component_path}"
end