Sha256: 2b7582ed9316e691882bec3c667a025590a958012dbd14ece1d7bafa4ea9ed60

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 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

  %w[
    date
    title
    subtitle
    description
    series_position
    campus_names
    topic
    topics
  ].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
    sermon_guide
    _clips
    _formatted
    _stats
  ].each do |att|
    define_method att do
      OpenStruct.new(raw[att]) if raw[att]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wcc-media-client-0.4.3 lib/wcc/media/message.rb
wcc-media-client-0.4.2 lib/wcc/media/message.rb
wcc-media-client-0.4.1 lib/wcc/media/message.rb
wcc-media-client-0.4.0 lib/wcc/media/message.rb
wcc-media-client-0.3.8 lib/wcc/media/message.rb
wcc-media-client-0.3.7 lib/wcc/media/message.rb
wcc-media-client-0.3.6 lib/wcc/media/message.rb