Sha256: e2d70a3968bcb5aca9a613e8af5ff56696b6676fe47b712ddb454581cae997d7
Contents?: true
Size: 727 Bytes
Versions: 1
Compression:
Stored size: 727 Bytes
Contents
# frozen_string_literal: true require 'contentful_model' module WCC::Contentful class Redirect < ContentfulModel::Base return_nil_for_empty :url, :pageReference class_attribute :load_depth self.load_depth = 10 self.content_type_id = 'redirect' def self.find_by_slug(slug) self.find_by(slug: slug).load_children(load_depth).load.first end def location if !self.url.nil? self.url elsif valid_page_reference?(self.pageReference) "/#{self.pageReference.url}" else nil end end def valid_page_reference?(page_ref) unless page_ref.nil? || defined?(page_ref.url).nil? true else false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wcc-contentful-0.0.2 | lib/wcc/contentful/redirect.rb |