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::ImmutableSortedSetOf, Contracts::PATH_MATCHER

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.


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

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

  @data = data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data


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

def data
  @data
end

Class Method Details

.deserialize(_app, key, attributes) ⇒ Object


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

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

.from_data(key, data) ⇒ Object


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

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

Instance Method Details

#merge!(other) ⇒ Object


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

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

#serializeObject


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

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

#valid?Boolean

Returns:

  • (Boolean)

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

def valid?
  current_hash == previous_hash
end