Skip to content

Idiomatic Ruby alignment pass #41

Description

@cassieemb

Summary

Bring three idiom classes in line with the project's own stated migration (see RUBY_ERGONOMICS_MIGRATION.md and .rubocop.yml):
(a) @ivar reads outside initialize → reader methods;
(b) leading-underscore "private" methods → real private/protected;
(c) ||= memoization → return @x if defined?(@x).

Where

Enumerate; line numbers drift:

  • (a) grep -nE '@[a-z_]+' lib/signalwire/agent/agent_base.rb; also relay/client.rb, relay/call.rb, and stateful skills (web_search.rb, datasphere.rb, weather_api.rb, joke.rb, wikipedia_search.rb).
  • (b) grep -rn 'def _' lib/ (e.g. in agent_base.rb, server/agent_server.rb, rest/http_client.rb).
  • (c) grep -rn '||=' lib/ (e.g. server/agent_server.rb, swml/service.rb, contexts/context_builder.rb, skills/builtin/wikipedia_search.rb).

Directive

Apply each transformation mechanically, one concern per commit (and ideally one file per commit for (a)).

For (a) add private attr_readers; leave @ivar assignments and genuinely-mutable concurrency state (mutexes/sockets/@state) alone.

For (b) make true internals private (protected for cross-instance helpers) and drop the redundant underscore.

For (c) convert to the defined? form.

Guardrails

Must not add any PUBLIC method (surface gate) or change behavior/wire output. Don't touch the get_/set_/has_ accessor names.

Acceptance

  • no @ivar reads outside initialize in the listed files (excluding deliberate mutable state)
  • no leading-underscore method names where private/protected suffices
  • no ||= lazy-init remains
  • rake test green
  • rubocop clean
  • public surface unchanged

Verify

rake test · bundle exec rubocop on changed files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions