Class: Ticket::Template
- Inherits:
-
Object
- Object
- Ticket::Template
- Defined in:
- app/models/ticket/template.rb
Overview
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
Instance Method Summary collapse
- #attributes ⇒ Object
- #build ⇒ Object
- #collect ⇒ Object
- #flatten ⇒ Object
-
#initialize(attrs = {}) ⇒ Template
constructor
A new instance of Template.
- #update_attributes(attrs) ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Template
Returns a new instance of Template.
9 10 11 |
# File 'app/models/ticket/template.rb', line 9 def initialize(attrs = {}) @attributes = attrs end |
Instance Method Details
#attributes ⇒ Object
17 18 19 |
# File 'app/models/ticket/template.rb', line 17 def attributes @attributes end |
#build ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/ticket/template.rb', line 25 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 |
#collect ⇒ Object
13 |
# File 'app/models/ticket/template.rb', line 13 def collect; self; end |
#flatten ⇒ Object
15 |
# File 'app/models/ticket/template.rb', line 15 def flatten; self; end |
#update_attributes(attrs) ⇒ Object
21 22 23 |
# File 'app/models/ticket/template.rb', line 21 def update_attributes(attrs) @attributes.merge!(attrs) end |