class ContentfulLite::Asset

Private Class Methods

asset_attribute(key, path, default: nil) click to toggle source

@api private @!macro [attach] asset_attribute

Returns the $1 attribute of the Contentful Asset
# File lib/contentful_lite/asset.rb, line 16
def self.asset_attribute(key, path, default: nil)
  define_method(key) do |locale: nil|
    path.inject(fields(locale: locale)) { |hash, path_section| hash.nil? ? nil : hash[path_section] } || default
  end
end

Public Instance Methods