Class: WCC::Contentful::IndexedRepresentation
- Inherits:
-
Object
- Object
- WCC::Contentful::IndexedRepresentation
show all
- Defined in:
- lib/wcc/contentful/indexed_representation.rb
Overview
The result of running the indexer on raw content types to produce a type definition which can be used to build models or graphql types.
Defined Under Namespace
Classes: ContentType, Field
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of IndexedRepresentation.
7
8
9
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 7
def initialize(types = {})
@types = types
end
|
Class Method Details
.from_json(hash) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 22
def self.from_json(hash)
hash = JSON.parse(hash) if hash.is_a?(String)
ret = IndexedRepresentation.new
hash.each do |id, content_type_hash|
ret[id] = ContentType.new(content_type_hash)
end
ret
end
|
Instance Method Details
#==(other) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 40
def ==(other)
my_keys = keys
return false unless my_keys == other.keys
my_keys.all? { |k| self[k] == other[k] }
end
|
#[]=(id, value) ⇒ Object
16
17
18
19
20
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 16
def []=(id, value)
raise ArgumentError unless value.is_a?(ContentType)
@types[id] = value
end
|
#deep_dup ⇒ Object
36
37
38
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 36
def deep_dup
self.class.new(@types.deep_dup)
end
|
#to_json(*args) ⇒ Object
32
33
34
|
# File 'lib/wcc/contentful/indexed_representation.rb', line 32
def to_json(*args)
@types.to_json(*args)
end
|