Class: AmberComponent::Base Abstract
- Inherits:
-
ActionView::Base
- Object
- ActionView::Base
- AmberComponent::Base
- Extended by:
- ActiveModel::Callbacks, Assets::ClassMethods, Helpers::ClassHelper, Props::ClassMethods, Rendering::ClassMethods, Views::ClassMethods, Memery
- Defined in:
- lib/amber_component/base.rb
Overview
This class is abstract.
Create a subclass to define a new component.
Abstract class which serves as a base for all Amber Components.
There are a few life cycle callbacks that can be defined. The same way as in ‘ActiveRecord` models and `ActionController` controllers.
-
before_render
-
around_render
-
after_render
-
before_initialize
-
around_initialize
-
after_initialize
class ButtonComponent < ::AmberComponent::Base # You can provide a Symbol of the method that should be called before_render :before_render_method # Or provide a block that will be executed after_initialize do # Your code here end def before_render_method # Your code here end end
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Views::ClassMethods
Attributes included from Props::ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #compiled_method_container ⇒ Class
-
#initialize(**kwargs) ⇒ Base
constructor
A new instance of Base.
Methods included from Helpers::ClassHelper
Methods included from Views::ClassMethods
view, view_file_name, view_path, view_template_source, view_type
Methods included from Assets::ClassMethods
all_asset_dir_paths, asset_dir_from_name, asset_dir_path, asset_file_names, asset_path
Methods included from Rendering::ClassMethods
compile, compile?, compiled?, render, template_handler
Methods included from Props::ClassMethods
prop, prop_names, required_prop_names
Methods included from Rendering::InstanceMethods
#nested_content, #render, #render_in, #safe_capture
Methods included from Helpers::CssHelper
Constructor Details
#initialize(**kwargs) ⇒ Base
Returns a new instance of Base.
145 146 147 148 149 150 151 |
# File 'lib/amber_component/base.rb', line 145 def initialize(**kwargs) run_callbacks :initialize do next if bind_props(kwargs) bind_instance_variables(kwargs) end end |
Class Method Details
.compiled_method_container ⇒ Class
65 66 67 |
# File 'lib/amber_component/base.rb', line 65 def compiled_method_container self end |
.format ⇒ Symbol
75 76 77 |
# File 'lib/amber_component/base.rb', line 75 def format :html end |
.identifier ⇒ String
80 81 82 |
# File 'lib/amber_component/base.rb', line 80 def identifier source_location.first end |
.type ⇒ String
70 71 72 |
# File 'lib/amber_component/base.rb', line 70 def type 'text/html' end |
Instance Method Details
#compiled_method_container ⇒ Class
154 155 156 |
# File 'lib/amber_component/base.rb', line 154 def compiled_method_container self.class end |