class LearnParty::Student

Attributes

collection[RW]

Public Class Methods

new(collection) click to toggle source
# File lib/learn_party.rb, line 53
def initialize(collection)
  @collection = collection
end

Public Instance Methods

generate_batch_students() click to toggle source
# File lib/learn_party.rb, line 57
def generate_batch_students
  if student_hash_type
    return collection.collect {|s| OpenStruct.new(s)}
  elsif student_instance_object_type
    return collection
  else
    raise StudentTypeError.new
  end
end
student_hash_type() click to toggle source
# File lib/learn_party.rb, line 67
def student_hash_type
  collection.first.is_a?(Hash) && (collection.first.keys.include?("completed_lesson_count_for_active_track" || :completed_lesson_count_for_active_track))
end
student_instance_object_type() click to toggle source
# File lib/learn_party.rb, line 71
def student_instance_object_type
  collection.first.respond_to?(:completed_lesson_count_for_active_track)
end