Class: Middleman::Dependencies::DataCollectionPathVertex

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

Constant Summary collapse

TYPE_ID =
:data_path
DATA_TYPE =
Or[Num, String, Symbol, 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

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?, #merge!, #to_s, #type_id

Constructor Details

#initialize(key, attributes, controller = nil) ⇒ DataCollectionPathVertex

Returns a new instance of DataCollectionPathVertex


26
27
28
29
30
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_path_vertex.rb', line 26

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

  @controller = controller
end

Class Method Details

.deserialize(app, key, attributes) ⇒ Object


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

def self.deserialize(app, key, attributes)
  DataCollectionPathVertex.new(key, attributes.symbolize_keys, app.data)
end

.from_data(app, path) ⇒ Object


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

def self.from_data(app, path)
  DataCollectionPathVertex.new(path.map(&:to_s).join('.').to_sym, {}, app.data)
end

Instance Method Details

#serializeObject


38
39
40
41
42
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_path_vertex.rb', line 38

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

#valid?Boolean

Returns:

  • (Boolean)

33
34
35
# File 'middleman-core/lib/middleman-core/dependencies/vertices/data_collection_path_vertex.rb', line 33

def valid?
  current_hash == previous_hash
end