drops: use def_delegator more liberally where acceptable
This commit is contained in:
parent
fcce0d5482
commit
b2b634e767
|
@ -6,6 +6,7 @@ module Jekyll
|
|||
class CollectionDrop < ImmutableDrop
|
||||
extend Forwardable
|
||||
|
||||
def_delegator :@obj, :write?, :output
|
||||
def_delegators :@obj, :label, :docs, :files, :directory,
|
||||
:relative_directory
|
||||
|
||||
|
@ -13,14 +14,8 @@ module Jekyll
|
|||
docs.to_s
|
||||
end
|
||||
|
||||
def output
|
||||
@obj.write?
|
||||
end
|
||||
|
||||
private
|
||||
def fallback_data
|
||||
@obj.metadata
|
||||
end
|
||||
def_delegator :@obj, :metadata, :fallback_data
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,22 +5,15 @@ module Jekyll
|
|||
class DocumentDrop < ImmutableDrop
|
||||
extend Forwardable
|
||||
|
||||
def_delegator :@obj, :next_doc, :next
|
||||
def_delegator :@obj, :previous_doc, :previous
|
||||
def_delegator :@obj, :relative_path, :path
|
||||
def_delegators :@obj, :id, :output, :content, :to_s, :relative_path, :url
|
||||
|
||||
alias_method :path, :relative_path
|
||||
|
||||
def collection
|
||||
@obj.collection.label
|
||||
end
|
||||
|
||||
def next
|
||||
@obj.next_doc
|
||||
end
|
||||
|
||||
def previous
|
||||
@obj.previous_doc
|
||||
end
|
||||
|
||||
def excerpt
|
||||
fallback_data['excerpt'].to_s
|
||||
end
|
||||
|
|
|
@ -30,9 +30,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
private
|
||||
def fallback_data
|
||||
@obj.config
|
||||
end
|
||||
def_delegator :@obj, :config, :fallback_data
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,18 +3,15 @@
|
|||
module Jekyll
|
||||
module Drops
|
||||
class UrlDrop < ImmutableDrop
|
||||
extend Forwardable
|
||||
|
||||
def_delegator :@obj, :cleaned_relative_path, :path
|
||||
def_delegator :@obj, :output_ext, :output_ext
|
||||
|
||||
def collection
|
||||
@obj.collection.label
|
||||
end
|
||||
|
||||
def path
|
||||
@obj.cleaned_relative_path
|
||||
end
|
||||
|
||||
def output_ext
|
||||
@obj.output_ext
|
||||
end
|
||||
|
||||
def name
|
||||
Utils.slugify(@obj.basename_without_ext)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue