Module: KalturaBox::Entry::Metadata
- Defined in:
- lib/kaltura_box/entry/metadata.rb,
lib/kaltura_box/entry/metadata/class_methods.rb,
lib/kaltura_box/entry/metadata/class_and_instance_methods.rb
Overview
The Metadata module provides methods that get/set and add metadata to the Kaltura installation.
Defined Under Namespace
Modules: ClassAndInstanceMethods, ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#add_attribute(attr_name, entry_id, value) ⇒ String
Appends a specific Kaltura::MediaEntry attribute to the end of the original attribute given a Kaltura entry.
- #category_exists?(category_name) ⇒ Boolean
-
#get_entry(entry_id) ⇒ Kaltura::MediaEntry
Gets a Kaltura::MediaEntry given a Kaltura entry.
- #method_missing(name, *args) ⇒ Object
- #respond_to?(method) ⇒ Boolean
-
#set(entry_id, attributes = {}) ⇒ Object
Sets multiple Kaltura::MediaEntry attributes in one convienant method.
-
#set_attribute(attr_name, entry_id, value) ⇒ String
Sets a specific Kaltura::MediaEntry attribute given a Kaltura entry.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kaltura_box/entry/metadata.rb', line 31 def method_missing(name, *args) method_name = name.to_s unless self.class.generated_methods? self.class.define_attribute_methods if self.class.generated_methods.include?(method_name) return self.send(name,*args) else super end else super end end |
Class Method Details
.included(base) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/kaltura_box/entry/metadata.rb', line 19 def self.included(base) base.extend ClassAndInstanceMethods base.extend ClassMethods base.class_eval do include ClassAndInstanceMethods end super end |
Instance Method Details
#add_attribute(attr_name, entry_id, value) ⇒ String
Appends a specific Kaltura::MediaEntry attribute to the end of the original attribute given a Kaltura entry. This method is called by method_missing, allowing this module add attributes based off of the current API wrapper, rather than having to update along side the API wrapper.
141 142 143 144 145 146 147 148 |
# File 'lib/kaltura_box/entry/metadata.rb', line 141 def add_attribute(attr_name,entry_id,value) client = KalturaBox::Client.update_session old_attributes = client.media_service.get(entry_id).send(attr_name.to_sym) media_entry = Kaltura::KalturaMediaEntry.new media_entry.send("#{attr_name}=","#{old_attributes},#{value}") client.media_service.update(entry_id,media_entry).send(attr_name.to_sym) end |
#category_exists?(category_name) ⇒ Boolean
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/kaltura_box/entry/metadata.rb', line 113 def category_exists?(category_name) client = KalturaBox::Client.update_session category_filter = Kaltura::KalturaCategoryFilter.new category_filter.full_name_equal = category_name category_check = client.category_service.list(category_filter).objects if category_check.nil? false else category_check end end |
#get_entry(entry_id) ⇒ Kaltura::MediaEntry
Gets a Kaltura::MediaEntry given a Kaltura entry.
67 68 69 70 |
# File 'lib/kaltura_box/entry/metadata.rb', line 67 def get_entry(entry_id) client = KalturaBox::Client.update_session client.media_service.get(entry_id) end |
#respond_to?(method) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kaltura_box/entry/metadata.rb', line 48 def respond_to?(method) case method.to_s when /^(get|set)_(.*)/ valid_entry_attribute?($2.to_sym) || super when /^(add)_(.*)/ (valid_entry_attribute?($2.pluralize.to_sym) && valid_add_attribute?($2) ) || super else super end end |
#set(entry_id, attributes = {}) ⇒ Object
Sets multiple Kaltura::MediaEntry attributes in one convienant method.
101 102 103 104 105 106 107 108 |
# File 'lib/kaltura_box/entry/metadata.rb', line 101 def set(entry_id, attributes={}) KalturaBox::Client.update_session attributes.each do |key,value| attribute = key.to_s set_attribute(attribute,entry_id,value) if valid_entry_attribute?(key) end end |
#set_attribute(attr_name, entry_id, value) ⇒ String
Sets a specific Kaltura::MediaEntry attribute given a Kaltura entry. This method is called by method_missing, allowing this module set attributes based off of the current API wrapper, rather than having to update along side the API wrapper.
86 87 88 89 90 91 92 |
# File 'lib/kaltura_box/entry/metadata.rb', line 86 def set_attribute(attr_name,entry_id,value) client = KalturaBox::Client.update_session media_entry = Kaltura::KalturaMediaEntry.new media_entry.send("#{attr_name}=",value) client.media_service.update(entry_id,media_entry).send(attr_name.to_sym) end |