Sha256: ad1cd9f87f2e42c73672e17c0fc2dfc66b365a197a1b88859f2d8425dd38c75c

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require_relative 'base'

class WCC::Media::Message < WCC::Media::Base
  active_record_shim do
    endpoint 'messages'
    filters %w[
      on_or_after_date
      on_or_before_date
      tag_id
      speaker_id
      scripture_book_id
      series_id
      title_like
      legacy_id
    ].freeze
  end

  def id
    raw['id']&.to_s
  end

  def legacy_id
    raw['legacy_id']&.to_s
  end

  %w[
    date
    title
    description
    series_position
  ].each do |att|
    define_method att do
      raw[att]
    end
  end

  def speakers
    (raw['speakers'] || []).map { |val| WCC::Media::Speaker.new(val) }
  end

  def tags
    (raw['tags'] || []).map { |val| WCC::Media::Tag.new(val) }
  end

  %w[
    scripture_references
    downloads
  ].each do |att|
    define_method att do
      (raw[att] || []).map { |val| OpenStruct.new(val) }
    end
  end

  def series
    WCC::Media::Series.new(raw['series']) if raw['series']
  end

  %w[
    embeds
    assets
    images
    external_urls
    transcript
  ].each do |att|
    define_method att do
      OpenStruct.new(raw[att]) if raw[att]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wcc-media-client-0.2.0 lib/wcc/media/message.rb