Class: EventBright::Ticket

Inherits:
ApiObject show all
Defined in:
lib/eventbright/api_objects/ticket.rb

Instance Attribute Summary collapse

Attributes inherited from ApiObject

#attributes, #collections, #dirty, #dirty_collections, #dirty_relations, #id, #owner, #relations

Instance Method Summary collapse

Methods inherited from ApiObject

#after_load, #after_update, #api_hash, #attribute_get, #attribute_set, #before_save, #clean!, #dirty?, #get_hash, #init, #init_with_hash, #inspect, #load, #load!, #loaded?, #nested_hash, #preinit, #prep_api_hash, #save, #to_s, #updatable_hash, #update_hash

Methods included from ApiObjectClassMethods

#collection, #collections, #has, #ignores, #plural_name, #readable, #readable_date, #reformats, #relations, #remap, #renames, #requires, #singlet_name, #updatable, #updatable_date

Methods included from ApiObjectRelationships

#collection_clean!, #collection_dirty!, #collection_dirty?, #collection_get, #collection_set, #collections_save, #load_collections_with_hash, #load_relations_with_hash, #relation_clean!, #relation_dirty!, #relation_dirty?, #relation_get, #relation_set, #relations_save, #unnest_child_response

Constructor Details

#initialize(event = nil, hash = {}) ⇒ Ticket

Tickets can’t live outside events, so we override standard owner to be event.

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
# File 'lib/eventbright/api_objects/ticket.rb', line 23

def initialize(event = nil, hash = {})
  preinit
  raise ArgumentError unless event.is_a? EventBright::Event
  @id = hash.delete(:id)
  @event = event
  @owner = event.owner
  init_with_hash(hash, true)
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



13
14
15
# File 'lib/eventbright/api_objects/ticket.rb', line 13

def event
  @event
end

Instance Method Details

#after_attribute_setObject



52
53
54
# File 'lib/eventbright/api_objects/ticket.rb', line 52

def after_attribute_set
  @event.dirty_tickets! unless @event.nil?
end

#after_newObject



44
45
46
# File 'lib/eventbright/api_objects/ticket.rb', line 44

def after_new
  @event.dirty_tickets!
end

#after_saveObject



48
49
50
# File 'lib/eventbright/api_objects/ticket.rb', line 48

def after_save
  @event.dirty_tickets!
end

#hideObject



36
37
38
# File 'lib/eventbright/api_objects/ticket.rb', line 36

def hide
  (["1", 1, "y", "Y"].include? attribute_get(:hide)) ? "y" : "n"
end

#new_hashObject



40
41
42
# File 'lib/eventbright/api_objects/ticket.rb', line 40

def new_hash
  {:event_id => @event.id}
end

#visible=(val, *args) ⇒ Object



32
33
34
# File 'lib/eventbright/api_objects/ticket.rb', line 32

def visible=(val,*args) 
  val == "1" || val == 1 ? attribute_set(:hide, 0, true) : attribute_set(:hide, 1, true)
end