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 | ||
| 3 | 1 | module EquivalenceCases |
| 4 | 1 | module AttributeValueMutation |
| 5 | # Serialising this value changes the component's state, which the | |
| 6 | # runtime has already read for the other attributes. | |
| 7 | 1 | class Mutating |
| 8 | 1 | def initialize(component) = @component = component |
| 9 | ||
| 10 | 1 | def to_h |
| 11 | 30 | @component.mutate |
| 12 | 30 | { a: "1" } |
| 13 | end | |
| 14 | end | |
| 15 | ||
| 16 | 1 | class AttributeValueMutation < Phlex::HTML |
| 17 | 1 | def initialize |
| 18 | 6 | @title = "before" |
| 19 | 6 | @active = true |
| 20 | end | |
| 21 | ||
| 22 | 1 | def mutate |
| 23 | 30 | @title = "after" |
| 24 | 30 | @active = false |
| 25 | end | |
| 26 | ||
| 27 | 1 | def view_template |
| 28 | 3 | div(id: Mutating.new(self), title: @title) |
| 29 | 3 | div(title: @title, id: Mutating.new(self)) |
| 30 | 3 | div(id: Mutating.new(self), class: @active ? "on" : "off")then never taken |
| 31 | 3 | div(id: Mutating.new(self), class: "x-#{@title}") |
| 32 | 3 | div(id: Mutating.new(self), class: "static") |
| 33 | end | |
| 34 | end | |
| 35 | end | |
| 36 | end |