Sha256: 12c7e284d1802b445b0bb42dbd9c715dca65d5045a97e87f3d84ae2ca160796a
Contents?: true
Size: 1.29 KB
Versions: 14
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true module Bridgetown module Model # Abstract Superclass class Origin extend ActiveSupport::DescendantsTracker EAGER_LOAD_DESCENDANTS = %i(BuilderOrigin RepoOrigin PluginOrigin).freeze # @return [String] attr_accessor :id # @return [Bridgetown::Site] attr_accessor :site # You must implement in subclasses def self.handle_scheme?(_scheme) false end def initialize(id, site: Bridgetown::Current.site) self.id = id self.site = site end # You can override in subclass def verify_model?(klass) collection_name = URI.parse(id).host.chomp(".collection") return klass.collection_name.to_s == collection_name if klass.respond_to?(:collection_name) klass.name == ActiveSupport::Inflector.classify(collection_name) end def read raise "Implement #read in a subclass of Bridgetown::Model::Origin" end # @return [Pathname] def relative_path raise "Implement #relative_path in a subclass of Bridgetown::Model::Origin" end def exists? raise "Implement #exists? in a subclass of Bridgetown::Model::Origin" end end Origin::EAGER_LOAD_DESCENDANTS.each { const_get _1 } end end
Version data entries
14 entries across 14 versions & 1 rubygems