quickdraw/compilation_equivalence_cases/attribute_value_mutation.rb

Lines

100%

20 of 20 covered

Branches

50%

1 of 2 covered

Methods

100%

5 of 5 covered

1# frozen_string_literal: true
2
31module EquivalenceCases
41 module AttributeValueMutation
5 # Serialising this value changes the component's state, which the
6 # runtime has already read for the other attributes.
71 class Mutating
81 def initialize(component) = @component = component
9
101 def to_h
1130 @component.mutate
1230 { a: "1" }
13 end
14 end
15
161 class AttributeValueMutation < Phlex::HTML
171 def initialize
186 @title = "before"
196 @active = true
20 end
21
221 def mutate
2330 @title = "after"
2430 @active = false
25 end
26
271 def view_template
283 div(id: Mutating.new(self), title: @title)
293 div(title: @title, id: Mutating.new(self))
303 div(id: Mutating.new(self), class: @active ? "on" : "off")then never taken
313 div(id: Mutating.new(self), class: "x-#{@title}")
323 div(id: Mutating.new(self), class: "static")
33 end
34 end
35 end
36end