Class: EmbeddedVideoAsset

Inherits:
EmbeddedAsset show all
Defined in:
app/models/embedded_video_asset.rb

Overview

STI subclass for embedded videos
Stores video-specific render options (autoplay, player type, etc.)
== Schema Information

Table name: embedded_assets
Database name: primary

id :bigint not null, primary key
asset_type :string
options :jsonb not null
parent_type :string not null
type :string
uuid :uuid not null
created_at :datetime not null
updated_at :datetime not null
asset_id :bigint
parent_id :bigint not null

Indexes

idx_embedded_assets_on_asset_and_type (asset_id,asset_type,type)
idx_embedded_assets_parent_asset (parent_type,parent_id,asset_type,asset_id)
index_embedded_assets_on_asset (asset_type,asset_id)
index_embedded_assets_on_type (type)
index_embedded_assets_on_uuid (uuid)

Constant Summary collapse

PERMITTED_OPTIONS =

Video-specific permitted options for controller

%i[
  autoplay muted loop controls
  player_type
  width height aspect_ratio
  title caption poster_url
  lazyload
].freeze

Instance Attribute Summary

Attributes inherited from EmbeddedAsset

#uuid

Instance Method Summary collapse

Methods inherited from EmbeddedAsset

#asset, faqs, for_asset_type, for_parent, images, #parent, products, #to_param, videos

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Models::EventPublishable

#publish_event

Instance Method Details

#render_optionsObject

Returns render options formatted for VideoProvider/oEmbed



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/embedded_video_asset.rb', line 62

def render_options
  {
    autoplay: autoplay,
    muted: muted,
    loop: loop,
    controls: controls,
    player_type: player_type,
    width: width,
    height: height,
    aspect_ratio: aspect_ratio,
    title: title,
    caption: caption,
    poster_url: poster_url,
    lazyload: lazyload
  }.compact
end