class WCC::Contentful::IndexedRepresentation::ContentType

Constants

ATTRIBUTES

Public Class Methods

new(hash_or_id = nil) click to toggle source
# File lib/wcc/contentful/indexed_representation.rb, line 56
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

Public Instance Methods

==(other) click to toggle source
# File lib/wcc/contentful/indexed_representation.rb, line 82
def ==(other)
  ATTRIBUTES.all? { |att| public_send(att) == other.public_send(att) }
end
deep_dup() click to toggle source
# File lib/wcc/contentful/indexed_representation.rb, line 74
def deep_dup
  dup_hash =
    ATTRIBUTES.each_with_object({}) do |att, h|
      h[att] = public_send(att)
    end
  self.class.new(dup_hash)
end