Module: KalturaBox::Category::ClassMethods
- Defined in:
- lib/kaltura_box/category/class_methods.rb
Instance Method Summary collapse
- #add(name, description, destroy_after_create = false) ⇒ Object
- #list ⇒ Object
- #update_all_categories! ⇒ Object
Instance Method Details
#add(name, description, destroy_after_create = false) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kaltura_box/category/class_methods.rb', line 26 def add(name, description, destroy_after_create = false) client = KalturaBox::Client.update_session category_svc = Kaltura::KalturaCategoryService.new(client) new_category = Kaltura::KalturaCategory.new new_category.name = name new_category.description = description if category = category_svc.add(new_category) @cat_obj = self.create( name: category.name, full_name: category.full_name, description: category.description, ref_id: category.id, entries_count: category.entries_count ) category_svc.delete(@cat_obj.ref_id) if destroy_after_create end @cat_obj end |
#list ⇒ Object
7 8 9 10 11 12 |
# File 'lib/kaltura_box/category/class_methods.rb', line 7 def list client = KalturaBox::Client.update_session category = Kaltura::KalturaCategoryService.new(client) category_list = category.list category_list.objects end |
#update_all_categories! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kaltura_box/category/class_methods.rb', line 14 def update_all_categories! list.each do |category| self.create( name: category.name, full_name: category.full_name, description: category.description, ref_id: category.id, entries_count: category.entries_count ) end end |