Sha256: a7d9d3082cc4d24231f8ac70d5758d1f77476a5950a71a711461be9c314e79df

Contents?: true

Size: 692 Bytes

Versions: 4

Compression:

Stored size: 692 Bytes

Contents

module Spektrix
  module Tickets
    class PriceList
      include Spektrix::Base
      collection_path "price-lists"

      after_find ->(r) do
        @@bands ||= Band.all.to_a
        @@ticket_types ||= Type.all.to_a
        if r.respond_to?(:price)
          r.price = [r.price] unless r.price.is_a?(Array)
          r.prices = r.price.collect do |price|
            price[:band] = @@bands.find {|b| b.id == price[:band][:id]}
            price[:ticket_type] = @@ticket_types.find {|t| t.id == price[:ticket_type][:id]}
            Price.new(price)
          end
        end
      end

      def self.find(id)
        all.to_a.find {|r| r.id.to_i == id }
      end




    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spektrix-0.0.2.5 lib/models/tickets/price_list.rb
spektrix-0.0.2.4 lib/models/tickets/price_list.rb
spektrix-0.0.2.3 lib/models/tickets/price_list.rb
spektrix-0.0.2.1 lib/models/tickets/price_list.rb