Class: Goat::ComponentUpdate

Inherits:
PageUpdate show all
Defined in:
lib/goat/common.rb

Instance Attribute Summary collapse

Attributes inherited from PageUpdate

#version

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(skel, mutations, added, removed) ⇒ ComponentUpdate

Returns a new instance of ComponentUpdate.



72
73
74
75
76
77
# File 'lib/goat/common.rb', line 72

def initialize(skel, mutations, added, removed)
  @skel = skel
  @mutations = mutations
  @added = added
  @removed = removed
end

Instance Attribute Details

#addedObject (readonly)

Returns the value of attribute added.



70
71
72
# File 'lib/goat/common.rb', line 70

def added
  @added
end

#mutationsObject (readonly)

Returns the value of attribute mutations.



70
71
72
# File 'lib/goat/common.rb', line 70

def mutations
  @mutations
end

#removedObject (readonly)

Returns the value of attribute removed.



70
71
72
# File 'lib/goat/common.rb', line 70

def removed
  @removed
end

#skelObject (readonly)

Returns the value of attribute skel.



70
71
72
# File 'lib/goat/common.rb', line 70

def skel
  @skel
end

Class Method Details

.from_hash(h) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/goat/common.rb', line 88

def self.from_hash(h)
  self.new(
    ComponentSkeleton.from_hash(h['skel']),
    h['mutations'],
    h['added'].map{|a| ComponentSkeleton.from_hash(a)},
    h['removed']
  )
end

Instance Method Details

#to_hashObject



79
80
81
82
83
84
85
86
# File 'lib/goat/common.rb', line 79

def to_hash
  {
    'skel' => @skel.to_hash,
    'mutations' => @mutations,
    'added' => @added.map(&:to_hash),
    'removed' => @removed
  }
end