Sha256: 3dd0155f762e735aec860949e6ec452870510a22d5cb910ee0c9d6d306c51597

Contents?: true

Size: 1.04 KB

Versions: 19

Compression:

Stored size: 1.04 KB

Contents

#TODO: This class is supposed to encapsulate creating a ticket so that whoever is creating the Ticket (section, show, etc..)
# will always have the tickets created properly.  Instead, this class take a hash of whatever the called passed in, so Tickets
# can be created with whatever attrs are passed in.  We want it to be very easy for callers to
# create tickets the exact same way every time.
#
# Do not use this class or method.  Instead, use Ticket.create_many

class Ticket::Template
  def initialize(attrs = {})
    @attributes = attrs
  end

  def collect; self; end

  def flatten; self; end

  def attributes
    @attributes
  end

  def update_attributes(attrs)
    @attributes.merge!(attrs)
  end

  def build
    count = @attributes.delete(:count).to_i
    organization_id = @attributes.delete(:organization_id)
    show_id = @attributes.delete(:show_id)
    
    tickets = []
    count.times.collect do 
      t = Ticket.new(attributes)
      t.organization_id = organization_id
      t.show_id = show_id
      tickets << t
    end
    tickets
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.15 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.12 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.11 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.10 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.9 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.8 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.7 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.6 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.5 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.4 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.3 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.2 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.1 app/models/ticket/template.rb
artfully_ose-1.2.0.pre app/models/ticket/template.rb
artfully_ose-1.1.0 app/models/ticket/template.rb
artfully_ose-1.1.0.rc2 app/models/ticket/template.rb
artfully_ose-1.1.0.rc1 app/models/ticket/template.rb
artfully_ose-1.0.0.rc4 app/models/ticket/template.rb
artfully_ose-1.0.0.rc3 app/models/ticket/template.rb