class WCC::Contentful::Link

Constants

Attributes

id[R]
raw[R]
to_h[R]

Public Class Methods

new(model, link_type = nil) click to toggle source
# File lib/wcc/contentful/link.rb, line 13
def initialize(model, link_type = nil)
  @id = model.try(:id) || model
  @link_type = link_type
  @link_type ||= model.is_a?(WCC::Contentful::Model::Asset) ? :Asset : :Link
  @raw =
    {
      'sys' => {
        'type' => 'Link',
        'linkType' => LINK_TYPES[@link_type] || link_type,
        'id' => @id
      }
    }
end