Class: PartialsFx::Component
- Inherits:
-
Object
- Object
- PartialsFx::Component
- Extended by:
- Attributes::ClassMethods, Slots::ClassMethods, Styles::ClassMethods
- Includes:
- ActionView::Helpers::TagHelper, ActiveModel::Attributes, ActiveModel::Model, Render, Styles
- Defined in:
- lib/partials_fx/component.rb,
lib/partials_fx/component/slots.rb,
lib/partials_fx/component/render.rb,
lib/partials_fx/component/styles.rb,
lib/partials_fx/component/attributes.rb
Defined Under Namespace
Modules: Attributes, Render, Slots, Styles
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#view_context ⇒ Object
Returns the value of attribute view_context.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**component_attributes) ⇒ Component
constructor
A new instance of Component.
- #method_missing(method, *arguments, &block) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #to_locals ⇒ Object
Methods included from Attributes::ClassMethods
attribute, required_attributes
Methods included from Slots::ClassMethods
Methods included from Styles::ClassMethods
component_styles, register_styles, styles
Methods included from Render
Methods included from Styles
Constructor Details
#initialize(**component_attributes) ⇒ Component
Returns a new instance of Component.
36 37 38 39 40 |
# File 'lib/partials_fx/component.rb', line 36 def initialize(**component_attributes) validate_required_attributes(component_attributes) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/partials_fx/component.rb', line 51 def method_missing(method, *arguments, &block) if respond_to_missing?(method) public_send(method, *arguments, &block) else super end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
24 25 26 |
# File 'lib/partials_fx/component.rb', line 24 def content @content end |
#view_context ⇒ Object
Returns the value of attribute view_context.
24 25 26 |
# File 'lib/partials_fx/component.rb', line 24 def view_context @view_context end |
Class Method Details
.inherited(subclass) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/partials_fx/component.rb', line 27 def inherited(subclass) super subclass.instance_eval do @pending_registration = true end end |
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
59 60 61 |
# File 'lib/partials_fx/component.rb', line 59 def respond_to_missing?(method, include_private = false) public_methods.include?(method) || super end |
#to_locals ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/partials_fx/component.rb', line 42 def to_locals base_locals = attributes.transform_keys(&:to_sym) base_locals .merge(public_methods(false).to_h { [_1, public_send(_1)] }) .merge(slot_locals) .merge(content: content, component_class: component_class) end |