Sha256: bd1090693b0985c2c9eacf821d520bb2250dfa7fc0788c7d8a36671a95e2048f
Contents?: true
Size: 736 Bytes
Versions: 1
Compression:
Stored size: 736 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.downcase).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.3 | lib/wcc/contentful/redirect.rb |