Class: Asset
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Asset
show all
- Includes:
- Sunrise::Models::Asset, Uploader::Asset
- Defined in:
- app/models/media/asset.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_klass(type) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'app/models/media/asset.rb', line 45
def self.find_klass(type)
_types = {
paper: 'Paper'
}
raise ActiveRecord::RecordNotFound, 'File not found' if _types[type.to_sym].nil?
_types[type.to_sym].safe_constantize
end
|
Instance Method Details
#uri ⇒ Object
35
36
37
|
# File 'app/models/media/asset.rb', line 35
def uri
@uri ||= URI(data.url)
end
|
#x_accel_url ⇒ Object
39
40
41
42
43
|
# File 'app/models/media/asset.rb', line 39
def x_accel_url
return url if uri.host.nil?
File.join('/private', uri.host, "#{uri.path}?#{uri.query}")
end
|