Sha256: 32f30d98d83b8d445c3f0a0cda8133569b71eabcf4b04f82b87eab4e78a7def6

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

module Spektrix
  module Events
    # An event instance.
    class Instance
      include Spektrix::Base
      collection_path "instances"

      after_find ->(r) do
        # parse times
        [:start,
         :start_utc,
         :start_selling_at,
         :start_selling_at_utc,
         :stop_selling_at,
         :stop_selling_at_utc
        ].each do |field|
          if r.respond_to?(field)
            time = Time.parse(r.send(field))
            if field.to_s =~ /_utc$/
              time = time.in_time_zone('UTC')
            else
              time = time.in_time_zone('London')
            end

            r.send(:"#{field}=",time)
          end
        end

        # we make price_list an actual Spektrix::Tickets:PriceList, but keep the original for reference
        r.price_list_id = r.price_list[:id].to_i

      end

      def status
        InstanceStatus.where(instance_id: self.id).first
      end

      def price_list
        Tickets::PriceList.where(instance_id: self.id).first
      end

      def event_object
        Event.where(event_id: event[:id]).first
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spektrix-0.0.2.1 lib/models/events/instance.rb