Class: SuperDiff::DiffFormatters::DefaultObject
- Defined in:
- lib/super_diff/diff_formatters/default_object.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(operations, value_class: nil, **rest) ⇒ DefaultObject
constructor
A new instance of DefaultObject.
Constructor Details
#initialize(operations, value_class: nil, **rest) ⇒ DefaultObject
Returns a new instance of DefaultObject.
8 9 10 11 12 |
# File 'lib/super_diff/diff_formatters/default_object.rb', line 8 def initialize(operations, value_class: nil, **rest) super(operations, **rest) @value_class = value_class end |
Class Method Details
.applies_to?(operations) ⇒ Boolean
4 5 6 |
# File 'lib/super_diff/diff_formatters/default_object.rb', line 4 def self.applies_to?(operations) operations.is_a?(OperationSequences::DefaultObject) end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/super_diff/diff_formatters/default_object.rb', line 14 def call Collection.call( open_token: "#<#{value_class} {", close_token: "}>", collection_prefix: collection_prefix, build_item_prefix: -> (operation) { key = if operation.respond_to?(:left_key) operation.left_key else operation.key end "@#{key}=" }, operations: operations, indent_level: indent_level, add_comma: add_comma?, ) end |