Class: WCC::Contentful::IndexedRepresentation::ContentType
- Inherits:
-
Object
- Object
- WCC::Contentful::IndexedRepresentation::ContentType
- Defined in:
- lib/wcc/contentful/indexed_representation.rb
Constant Summary collapse
- ATTRIBUTES =
%i[ name content_type fields ].freeze
Instance Method Summary collapse
-
#initialize(hash_or_id = nil) ⇒ ContentType
constructor
A new instance of ContentType.
Constructor Details
#initialize(hash_or_id = nil) ⇒ ContentType
Returns a new instance of ContentType.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/wcc/contentful/indexed_representation.rb', line 44 def initialize(hash_or_id = nil) @fields = {} return unless hash_or_id if hash_or_id.is_a?(String) @name = hash_or_id return end if raw_fields = (hash_or_id.delete('fields') || hash_or_id.delete(:fields)) raw_fields.each do |field_name, raw_field| @fields[field_name] = Field.new(raw_field) end end hash_or_id.each { |k, v| public_send("#{k}=", v) } end |