Module: Locomotive::Wagon::PersistAssetsConcern

Included in:
ContentEntryDecorator, EditableElementDecorator, PageDecorator, SectionDecorator, SiteDecorator, SnippetDecorator
Defined in:
lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb

Instance Method Summary collapse

Instance Method Details

#asset_io(local_path) ⇒ Object



22
23
24
# File 'lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb', line 22

def asset_io(local_path)
  __content_assets_pusher__.decorate(local_path).source
end

#replace_with_content_assets!(text) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb', line 7

def replace_with_content_assets!(text)
  return text if text.blank?

  text.to_s.gsub(/([^a-zA-Z0-9]|^)(\/samples\/[\/a-zA-Z0-9_-]+(\.[a-zA-Z0-9]+)*)/) do
    url = __content_assets_pusher__.persist($2) || $2
    $1 + url
  end
end

#replace_with_content_assets_in_hash!(hash) ⇒ Object



16
17
18
19
20
# File 'lib/locomotive/wagon/decorators/concerns/persist_assets_concern.rb', line 16

def replace_with_content_assets_in_hash!(hash)
  Locomotive::Wagon::YamlExt.transform(hash) do |value|
    replace_with_content_assets!(value)
  end
end