class ChangeDrop

Wrap a Change in a Drop that our Element Liquid::Templates can use to emit either values-alone or keys-and-values for any attribute of any one variation ot a media file.

Public Class Methods

new(change) click to toggle source
# File lib/distorted-jekyll/liquid_liquid.rb, line 235
def initialize(change)
  @change = change
end

Public Instance Methods

attr() click to toggle source
# File lib/distorted-jekyll/liquid_liquid.rb, line 241
def attr
  # Use a ChangeAttrDrop to avoid emitting keys for empty values.
  # It will respond to its own Change-key method just like we do.
  @attr ||= Cooltrainer::ChangeAttrDrop.new(@change)
end
initialism() click to toggle source
# File lib/distorted-jekyll/liquid_liquid.rb, line 238
def initialism
  @initialism ||= @change.type&.sub_type&.to_s.split(MIME::Type::SUB_TYPE_SEPARATORS)[0].upcase
end
liquid_method_missing(method) click to toggle source
Calls superclass method
# File lib/distorted-jekyll/liquid_liquid.rb, line 246
def liquid_method_missing(method)
  # Liquid will send us String keys only, so translate them
  # to Symbols when looking up in the Change Struct.
  # Don't explicitly call :to_s before returning,
  # because we might be returning an Array.
  @change&.send(method.to_sym) || super
end