Sha256: fb3b014b6dac30d858f73238cb2cfe65b1b58fc0d0ae287b79d782cb8810d652

Contents?: true

Size: 531 Bytes

Versions: 7

Compression:

Stored size: 531 Bytes

Contents

# frozen_string_literal: true

class WCC::Contentful::Model::MenuButton < WCC::Contentful::Model
  validate_field :text, :String, :required
  validate_field :icon, :Asset, :optional
  validate_field :external_link, :String, :optional
  validate_field :link, :Link, :optional, link_to: 'page'

  # Gets either the external link or the slug from the referenced page.
  # Example usage: `<%= link_to button.title, button.href %>`
  def href
    return external_link if external_link

    link&.try(:slug) || link&.try(:url)
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
wcc-contentful-app-0.4.0.pre.rc lib/wcc/contentful/model/menu_button.rb
wcc-contentful-app-0.4.0.pre.alpha lib/wcc/contentful/model/menu_button.rb
wcc-contentful-0.3.0 lib/wcc/contentful/model/menu_button.rb
wcc-contentful-app-0.3.0.pre.rc3 lib/wcc/contentful/model/menu_button.rb
wcc-contentful-app-0.3.0.pre.rc2 lib/wcc/contentful/model/menu_button.rb
wcc-contentful-app-0.3.0.pre.rc lib/wcc/contentful/model/menu_button.rb
wcc-contentful-app-0.2.2 lib/wcc/contentful/model/menu_button.rb