Class: Locomotive::Wagon::ContentAssetDecorator

Inherits:
Struct
  • Object
show all
Includes:
ToHashConcern
Defined in:
lib/locomotive/wagon/decorators/content_asset_decorator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ToHashConcern

#prepare_value_for_hash, #to_hash

Instance Attribute Details

#filepathObject

Returns the value of attribute filepath

Returns:

  • (Object)

    the current value of filepath



4
5
6
# File 'lib/locomotive/wagon/decorators/content_asset_decorator.rb', line 4

def filepath
  @filepath
end

Instance Method Details

#__attributes__Object



8
9
10
# File 'lib/locomotive/wagon/decorators/content_asset_decorator.rb', line 8

def __attributes__
  %i(source)
end

#checksumObject



16
17
18
# File 'lib/locomotive/wagon/decorators/content_asset_decorator.rb', line 16

def checksum
  Digest::MD5.hexdigest(_readfile(filepath) { |io| io.read })
end

#filenameObject



20
21
22
# File 'lib/locomotive/wagon/decorators/content_asset_decorator.rb', line 20

def filename
  File.basename(filepath)
end

#sourceObject



12
13
14
# File 'lib/locomotive/wagon/decorators/content_asset_decorator.rb', line 12

def source
  Locomotive::Coal::UploadIO.new(_readfile(filepath), nil, filename)
end