class WCC::Contentful::IndexedRepresentation::Field
Constants
- ATTRIBUTES
- TYPES
Public Class Methods
new(hash_or_id = nil)
click to toggle source
# File lib/wcc/contentful/indexed_representation.rb, line 118 def initialize(hash_or_id = nil) return unless hash_or_id if hash_or_id.is_a?(String) @name = hash_or_id return end unless hash_or_id.is_a?(Hash) ATTRIBUTES.each { |att| public_send("#{att}=", hash_or_id.public_send(att)) } return end if raw_type = hash_or_id.delete('type') raw_type = raw_type.to_sym unless TYPES.include?(raw_type) raise ArgumentError, "Unknown type #{raw_type}, expected one of: #{TYPES}" end @type = raw_type 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 143 def ==(other) ATTRIBUTES.all? { |att| public_send(att) == other.public_send(att) } end
type=(raw_type)
click to toggle source
# File lib/wcc/contentful/indexed_representation.rb, line 110 def type=(raw_type) unless TYPES.include?(raw_type) raise ArgumentError, "Unknown type #{raw_type}, expected one of: #{TYPES}" end @type = raw_type end