Class: WCC::Contentful::Model::Redirect

Inherits:
WCC::Contentful::Model show all
Defined in:
lib/wcc/contentful/model/redirect.rb

Constant Summary

Constants included from ServiceAccessors

ServiceAccessors::SERVICES

Instance Method Summary collapse

Methods inherited from WCC::Contentful::Model

const_missing, find, new_from_raw, register_for_content_type, registered?, registry, resolve_constant

Methods included from Helpers

#constant_from_content_type, #content_type_from_constant, #content_type_from_raw, #shared_prefix

Methods included from WCC::Contentful::ModelValidators

#no_validate_field, #schema, transform_content_types_for_validation, #validate_field, #validate_fields, #validations

Instance Method Details

#hrefObject



4
5
6
7
8
9
10
# File 'lib/wcc/contentful/model/redirect.rb', line 4

def href
  if !url.nil?
    url
  elsif valid_page_reference?(pageReference)
    "/#{pageReference.url}"
  end
end

#valid_page_reference?(page_ref) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
# File 'lib/wcc/contentful/model/redirect.rb', line 12

def valid_page_reference?(page_ref)
  if !page_ref.nil? && !defined?(page_ref.url).nil?
    true
  else
    false
  end
end