Class: Axn::Core::ContextFacadeInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/axn/core/context/facade_inspector.rb

Instance Method Summary collapse

Constructor Details

#initialize(action:, facade:, context:) ⇒ ContextFacadeInspector

Returns a new instance of ContextFacadeInspector.



16
17
18
19
20
# File 'lib/axn/core/context/facade_inspector.rb', line 16

def initialize(action:, facade:, context:)
  @action = action
  @facade = facade
  @context = context
end

Instance Method Details

#callObject

inspect composes at three nested levels, and EACH LEVEL NORMALIZES ITS OWN OPERANDS through rendered — never by trusting what the level below happened to return.

That is the whole discipline, and it is the opposite of rendering per-OPERAND: an Encoding::CompatibilityError needs two INCOMPATIBLE operands, so a join that renders some of what it receives and not the rest converts a working composition into a raise. Deciding which is which means ENUMERATING the branches that can feed the join, and that enumeration is exactly what kept being incomplete — a to_fs(:inspect) branch reachable through the documented Date::DATE_FORMATS extension point, and an ActiveRecord-relation branch, both of which format_for_inspect can return and neither of which was covered by rendering its other branches. Normalizing at the join makes the branch count irrelevant, present and future.

Here that means status and visible_fields, each of which is one of several shapes its own method chose. class_name is not normalized because it is not foreign: it is the facade's OWN class (an Axn::Result or a context facade), named by axn.



37
38
39
40
41
# File 'lib/axn/core/context/facade_inspector.rb', line 37

def call
  str = [rendered(status), rendered(visible_fields)].compact_blank.join(" ")

  "#<#{class_name} #{str}>"
end

#rendered(value) ⇒ Object

THE normalization point every join in this class runs its operands through: a UTF-8 String axn owns, for any object, without letting that object's own to_s replace the inspect being built. Byte-identical for ASCII, so ordinary output does not move.

nil passes through as nil rather than becoming "", because call distinguishes them — compact_blank drops an absent status so an inputs facade reads #<… a: 1> rather than #<… a: 1>.



49
50
51
52
53
# File 'lib/axn/core/context/facade_inspector.rb', line 49

def rendered(value)
  return value if Axn::Internal::Identity.nil_value?(value)

  Axn::Internal::Rendering.value_rendering(value) || Axn::Internal::Rendering.class_name(value)
end