Class: Phlex::Reactive::Inspector::ActionInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/phlex/reactive/inspector.rb

Overview

One declared action's introspection.

* source_location — klass.instance_method(name).source_location, or nil
                  when the action is declared but the method is
                  missing (the endpoint would 500 on public_send).
* definition      — the full `def ... end` source, extracted with Prism.
                  nil when the method is missing or its file is
                  unreadable/unparseable (degrade, never raise).
* authorization_call_detected? — a HEURISTIC: true when the Prism scan
                  of the definition finds a call to any configured
                  authorization method or mark_authorized!. A helper
                  may authorize indirectly, so this is advisory ONLY.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition

Returns:

  • (Object)

    the current value of definition



34
35
36
# File 'lib/phlex/reactive/inspector.rb', line 34

def definition
  @definition
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



34
35
36
# File 'lib/phlex/reactive/inspector.rb', line 34

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



34
35
36
# File 'lib/phlex/reactive/inspector.rb', line 34

def params
  @params
end

#source_locationObject (readonly)

Returns the value of attribute source_location

Returns:

  • (Object)

    the current value of source_location



34
35
36
# File 'lib/phlex/reactive/inspector.rb', line 34

def source_location
  @source_location
end

Instance Method Details

#authorization_call_detected?Boolean

Was any authorization method (or mark_authorized!) called directly in the method body? Heuristic — a Prism scan of definition. False when the definition is unavailable.

Returns:

  • (Boolean)


38
39
40
41
42
# File 'lib/phlex/reactive/inspector.rb', line 38

def authorization_call_detected?
  return false unless definition

  Inspector.authorization_call?(definition)
end