Class: Bridgetown::Model::Origin
- Inherits:
-
Object
- Object
- Bridgetown::Model::Origin
show all
- Extended by:
- ActiveSupport::DescendantsTracker
- Defined in:
- lib/bridgetown-core/model/origin.rb
Overview
Constant Summary
collapse
- EAGER_LOAD_DESCENDANTS =
%i(BuilderOrigin RepoOrigin PluginOrigin).freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(id, site: Bridgetown::Current.site) ⇒ Origin
Returns a new instance of Origin.
22
23
24
25
|
# File 'lib/bridgetown-core/model/origin.rb', line 22
def initialize(id, site: Bridgetown::Current.site)
self.id = id
self.site = site
end
|
Instance Attribute Details
#id ⇒ String
12
13
14
|
# File 'lib/bridgetown-core/model/origin.rb', line 12
def id
@id
end
|
15
16
17
|
# File 'lib/bridgetown-core/model/origin.rb', line 15
def site
@site
end
|
Class Method Details
.handle_scheme?(_scheme) ⇒ Boolean
You must implement in subclasses
18
19
20
|
# File 'lib/bridgetown-core/model/origin.rb', line 18
def self.handle_scheme?(_scheme)
false
end
|
Instance Method Details
#exists? ⇒ Boolean
45
46
47
|
# File 'lib/bridgetown-core/model/origin.rb', line 45
def exists?
raise "Implement #exists? in a subclass of Bridgetown::Model::Origin"
end
|
#read ⇒ Object
36
37
38
|
# File 'lib/bridgetown-core/model/origin.rb', line 36
def read
raise "Implement #read in a subclass of Bridgetown::Model::Origin"
end
|
#relative_path ⇒ Pathname
41
42
43
|
# File 'lib/bridgetown-core/model/origin.rb', line 41
def relative_path
raise "Implement #relative_path in a subclass of Bridgetown::Model::Origin"
end
|
#verify_model?(klass) ⇒ Boolean
You can override in subclass
28
29
30
31
32
33
34
|
# File 'lib/bridgetown-core/model/origin.rb', line 28
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
|