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

Instance Method Details

#build_inspect_string(*attributes, suffix: ">") ⇒ String

Builds a formatted inspect string from the given attribute names.

Parameters:

  • attributes (Array<Symbol>)

    The attribute names to include in the inspect output

  • suffix (String) (defaults to: ">")

    Optional suffix to append (default: “>”)

Returns:

  • (String)

    The formatted inspect string



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