Class: MediaContext
- Inherits:
-
Context
- Object
- Context
- MediaContext
- Includes:
- Mongoid::Document
- Defined in:
- app/models/contexts/media_context.rb
Overview
Base context for media data such as audio or video
Instance Method Summary (collapse)
- - (Object) as_json(options = {})
-
- (Object) source
Returns the url source of the included media.
- - (Boolean) source?
Methods inherited from Context
#context_type, #set_default_position
Instance Method Details
- (Object) as_json(options = {})
26 27 28 29 |
# File 'app/models/contexts/media_context.rb', line 26 def as_json( = {}) .merge!({ :only => [:asset_id, :source, :media_type ]}) super() end |
- (Object) source
Returns the url source of the included media. If an attached asset is found, it returns the paperclip generated url, otherwise the `source` attribute is returned.
17 18 19 20 |
# File 'app/models/contexts/media_context.rb', line 17 def source return read_attribute("source") if self.asset_id.nil? self.asset.file.url(:original) end |
- (Boolean) source?
22 23 24 |
# File 'app/models/contexts/media_context.rb', line 22 def source? (source.nil? or source.to_s.blank?) end |