Sha256: ed9eb648bffeba1c343b4c813a34fbf1abf8f7142c73b12516272b75d0939006

Contents?: true

Size: 1.23 KB

Versions: 50

Compression:

Stored size: 1.23 KB

Contents

require 'delegate'

module ACTV
  class Evergreen < ::SimpleDelegator
    attr_accessor :asset, :current_event, :events

    def initialize asset
      super asset
      @asset = asset
      @events = []
      @current_event = {}
      asset.evergreenAssets.each do |sub_asset|
        @events << SubEvent.new(sub_asset)
        @current_event = sub_asset if Time.parse(sub_asset.fetch(:activityEndDate, "1970-01-01T00:00:01")) > Time.parse(@current_event.fetch(:activityEndDate, "1970-01-01T00:00:01"))
      end
      @events = @events.sort_by { |event| event.end_date }.reverse
      @current_event = ACTV.event @current_event[:assetGuid]

      self
    end

    def evergreen?
      true
    end

    def components
      @current_event.components
    end

    def legacy_data
      @current_event.legacy_data
    end

    def description_by_type type
      asset_description = @asset.description_by_type type rescue nil

      if asset_description.present?
        asset_description
      else
        @current_event.description_by_type type
      end
    end

    def method_missing method, *args, &block
      begin
        @asset.send(method, *args)
      rescue NoMethodError => e
        @current_event.send(method, *args)
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
actv-2.10.9 lib/actv/evergreen.rb
actv-2.10.8 lib/actv/evergreen.rb
actv-2.10.7 lib/actv/evergreen.rb
actv-2.10.6 lib/actv/evergreen.rb
actv-2.10.5 lib/actv/evergreen.rb
actv-2.10.4 lib/actv/evergreen.rb
actv-2.10.3 lib/actv/evergreen.rb
actv-2.10.2 lib/actv/evergreen.rb
actv-2.10.1 lib/actv/evergreen.rb
actv-2.10.0 lib/actv/evergreen.rb
actv-2.9.2 lib/actv/evergreen.rb
actv-2.9.1 lib/actv/evergreen.rb
actv-2.9.0 lib/actv/evergreen.rb
actv-2.8.2 lib/actv/evergreen.rb
actv-2.8.1 lib/actv/evergreen.rb
actv-2.7.0 lib/actv/evergreen.rb
actv-2.6.0 lib/actv/evergreen.rb
actv-2.5.2 lib/actv/evergreen.rb
actv-2.5.1 lib/actv/evergreen.rb
actv-2.5.0 lib/actv/evergreen.rb