Module: RTunesU::Persistence::Finder

Defined in:
lib/rtunesu/persistence.rb

Instance Method Summary collapse

Instance Method Details

#find(handle, connection = nil) ⇒ Object

Finds a specific entity in iTunes U. To find an entity you will need to know both its type (Course, Group, etc) and handle. Handles uniquely identify entities in iTunes U and the entity type is used to search the returned XML for the specific entity you are looking for. For example, Course.find(123456, rtunes_connection_object)



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rtunesu/persistence.rb', line 8

def find(handle, connection = nil)
  connection ||= self.base_connection

  entity = self.new
  entity.instance_variable_set('@handle', handle)
  entity.load_from_xml(connection.upload_file(RTunesU::SHOW_TREE_FILE, handle))
  entity

rescue LocationNotFound
  raise EntityNotFound, "Could not find #{entity.class_name} with handle of #{handle}."
end