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
- Includes:
- Assets::InstanceMethods, Helpers::CssHelper, Props::InstanceMethods, Rendering::InstanceMethods, Views::InstanceMethods
- 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
Instance Method Summary collapse
-
#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_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
Methods included from Props::ClassMethods
prop, prop_names, required_prop_names
Methods included from Rendering::InstanceMethods
Methods included from Helpers::CssHelper
Constructor Details
#initialize(**kwargs) ⇒ Base
Returns a new instance of Base.
125 126 127 128 129 130 131 |
# File 'lib/amber_component/base.rb', line 125 def initialize(**kwargs) run_callbacks :initialize do next if bind_props(kwargs) bind_instance_variables(kwargs) end end |