Class: Panda::Core::Admin::AttributeDiffComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/attribute_diff_component.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changes:, heading: "Attribute Changes", **attrs) ⇒ AttributeDiffComponent

Returns a new instance of AttributeDiffComponent.



7
8
9
10
11
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 7

def initialize(changes:, heading: "Attribute Changes", **attrs)
  @changes = changes
  @heading = heading
  super(**attrs)
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



13
14
15
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 13

def changes
  @changes
end

#headingObject (readonly)

Returns the value of attribute heading.



13
14
15
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 13

def heading
  @heading
end

Instance Method Details

#display_value(value) ⇒ Object



19
20
21
22
23
24
25
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 19

def display_value(value)
  if value.is_a?(FalseClass) || value.is_a?(TrueClass)
    value.to_s
  else
    value.presence || "(empty)"
  end
end

#render?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 15

def render?
  changes.any?
end