Sha256: ce2bd4800564a7c1d5da78e86b7562349096f108a6136eb24c946af08d9a3a14

Contents?: true

Size: 1.06 KB

Versions: 17

Compression:

Stored size: 1.06 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
      t.set_uuid
      tickets << t
    end
    tickets
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre3 app/models/ticket/template.rb
artfully_ose-1.3.0.pre2 app/models/ticket/template.rb
artfully_ose-1.3.0.pre1 app/models/ticket/template.rb
artfully_ose-1.2.0 app/models/ticket/template.rb
artfully_ose-1.2.0.beta.1 app/models/ticket/template.rb
artfully_ose-1.2.0.alpha.2 app/models/ticket/template.rb
artfully_ose-1.2.0.alpha.1 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.27 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.26 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.24 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.23 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.21 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.20 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.19 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.18 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.17 app/models/ticket/template.rb
artfully_ose-1.2.0.pre.16 app/models/ticket/template.rb