Class: JsxRosetta::IR::StimulusMethod

Inherits:
Data
  • Object
show all
Includes:
Node
Defined in:
lib/jsx_rosetta/ir/types.rb

Overview

A handler method to be emitted on the generated Stimulus controller. Body translation is deferred to the human reviewer; we preserve the original JS body verbatim.

name : String — camelCase Stimulus method name (uniquified

when two handlers collide on the same base name).

body_source : String — verbatim JS body (the entire arrow function

or the function expression body), preserved as a
comment in the emitted controller skeleton.

original_name : String — the requested base name before uniquification.

Equals `name` when there was no collision. When
`name != original_name`, backends emit a collision
marker comment in the generated controller JS so the
reviewer can see the silent rename.

params : [String | nil] — original arrow/function parameter

names (e.g. `["e"]`, `["event"]`, or `[]` for
`() => …`). A `nil` entry signals a non-identifier
param (destructured `({target}) =>`, rest `(...args) =>`)
that the pasted body can't safely reference — backends
bail to the TODO form when any entry is nil.

body_is_block : Boolean — true when the arrow body was a BlockStatement

(`(e) => { … }`), false for an expression-form body
(`(e) => doX(e)`). Backends use this to decide whether
to strip outer braces when pasting verbatim.

Instance Attribute Summary collapse

Instance Attribute Details

#body_is_blockObject (readonly)

Returns the value of attribute body_is_block

Returns:

  • (Object)

    the current value of body_is_block



473
474
475
# File 'lib/jsx_rosetta/ir/types.rb', line 473

def body_is_block
  @body_is_block
end

#body_sourceObject (readonly)

Returns the value of attribute body_source

Returns:

  • (Object)

    the current value of body_source



473
474
475
# File 'lib/jsx_rosetta/ir/types.rb', line 473

def body_source
  @body_source
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



473
474
475
# File 'lib/jsx_rosetta/ir/types.rb', line 473

def name
  @name
end

#original_nameObject (readonly)

Returns the value of attribute original_name

Returns:

  • (Object)

    the current value of original_name



473
474
475
# File 'lib/jsx_rosetta/ir/types.rb', line 473

def original_name
  @original_name
end

#paramsObject (readonly)

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



473
474
475
# File 'lib/jsx_rosetta/ir/types.rb', line 473

def params
  @params
end