Class: Panda::Core::Admin::AttributeDiffComponent
- Defined in:
- app/components/panda/core/admin/attribute_diff_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#heading ⇒ Object
readonly
Returns the value of attribute heading.
Instance Method Summary collapse
- #display_value(value) ⇒ Object
-
#initialize(changes:, heading: "Attribute Changes", **attrs) ⇒ AttributeDiffComponent
constructor
A new instance of AttributeDiffComponent.
- #render? ⇒ Boolean
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
#changes ⇒ Object (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 |
#heading ⇒ Object (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
15 16 17 |
# File 'app/components/panda/core/admin/attribute_diff_component.rb', line 15 def render? changes.any? end |