Class: Mural::Widget::Arrow::Label

Inherits:
Object
  • Object
show all
Includes:
Codec
Defined in:
lib/mural/widget/arrow.rb

Defined Under Namespace

Classes: Format, Label

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Codec

included

Class Method Details

.decode(json) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/mural/widget/arrow.rb', line 78

def self.decode(json)
  super.tap do |label|
    next if label.nil?

    label.labels = label.labels.map do |l|
      # I'm not responsible for this naming…
      Mural::Widget::Arrow::Label::Label.decode(l)
    end

    label.format = Format.decode(label.format)
  end
end

Instance Method Details

#encodeObject



91
92
93
94
95
96
# File 'lib/mural/widget/arrow.rb', line 91

def encode
  super.tap do |json|
    json['format'] = json['format']&.encode
    json['labels']&.map!(&:encode)
  end.compact
end