Module: LocoMotion::Concerns::InspectableComponent
- Included in:
- BaseComponent, LocoMotion::ComponentConfig
- Defined in:
- lib/loco_motion/concerns/inspectable_component.rb
Overview
Provides a formatted inspect method for components
This concern offers a shared way to build readable inspect strings for components and configuration objects using format strings.
Instance Method Summary collapse
-
#build_inspect_string(*attributes, suffix: ">") ⇒ String
Builds a formatted inspect string from the given attribute names.
Instance Method Details
#build_inspect_string(*attributes, suffix: ">") ⇒ String
Builds a formatted inspect string from the given attribute names.
17 18 19 20 21 22 |
# File 'lib/loco_motion/concerns/inspectable_component.rb', line 17 def build_inspect_string(*attributes, suffix: ">") format("#<%<class>s %<attributes>s%<suffix>s", class: self.class.name, attributes: attributes.map { |attr| "@#{attr}=#{send(attr).inspect}" }.join(" "), suffix: suffix) end |