Class: Middleman::Dependencies::DataCollectionVertex

Inherits:
Vertex
  • Object
show all
Includes:
Contracts
Defined in:
middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb

Constant Summary collapse

TYPE_ID =
:data
DATA_TYPE =
Or[Hash, Array]

Constants included from Contracts

Contracts::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

Constants inherited from Vertex

Vertex::SERIALIZED_VERTEX, Vertex::SERIALIZED_VERTEX_ATTRS, Vertex::VERTEX_ATTRS, Vertex::VERTEX_KEY

Instance Attribute Summary collapse

Attributes inherited from Vertex

#attributes, #key

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Contracts

#Contract

Methods inherited from Vertex

#==, #matches_resource?, #to_s, #type_id

Constructor Details

#initialize(key, attributes, data = nil) ⇒ DataCollectionVertex

Returns a new instance of DataCollectionVertex



28
29
30
31
32
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 28

def initialize(key, attributes, data = nil)
  super(key, attributes)

  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data



15
16
17
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 15

def data
  @data
end

Class Method Details

.deserialize(_app, key, attributes) ⇒ Object



18
19
20
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 18

def self.deserialize(_app, key, attributes)
  DataCollectionVertex.new(key, attributes.symbolize_keys)
end

.from_data(key, data) ⇒ Object



23
24
25
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 23

def self.from_data(key, data)
  DataCollectionVertex.new(key, {}, data)
end

Instance Method Details

#merge!(other) ⇒ Object



40
41
42
43
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 40

def merge!(other)
  super
  @data = other.data if @data.nil?
end

#serializeObject



46
47
48
49
50
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 46

def serialize
  super({
    hash: current_hash || previous_hash
  })
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_vertex.rb', line 35

def valid?
  current_hash == previous_hash
end