Module: KalturaFu::Entry::Metadata::ClassAndInstanceMethods

Defined in:
lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb

Overview

It is necessary to have the check for valid Kaltura MediaEntry methods available at both the class and instance level, so they are thrown into this module.

Instance Method Summary collapse

Instance Method Details

#valid_add_attribute?(request_attribute) ⇒ Boolean

Determines if an attribute is valid in the sense of the add method making sense. Only categories and tags are currently considered valid.



39
40
41
42
43
44
45
46
47
48
# File 'lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb', line 39

def valid_add_attribute?(request_attribute)
  case request_attribute.to_s
    when /^(.*)_(categories|tags)/ 
      return true
    when /^(categories|tags)/
      return true
  else
    return false
  end 
end

#valid_entry_attribute?(request_attribute) ⇒ Boolean

Checks if a requested attribute is in fact a valid MediaEntry atrribute.



14
15
16
17
18
19
20
21
22
# File 'lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb', line 14

def valid_entry_attribute?(request_attribute)
  object_methods, media_entry_methods = Object.instance_methods , Kaltura::MediaEntry.instance_methods

  #clean out all the setter methods from the media entry methods
  valid_media_entry_methods = media_entry_methods.map{|m| m unless m =~/^(.*)=/}.compact!

  valid_media_entry_methods -= object_methods
  valid_entry_attributes.include?(request_attribute.to_sym)
end

#valid_entry_attributesObject



27
28
29
30
31
32
33
34
# File 'lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb', line 27

def valid_entry_attributes
  object_methods, media_entry_methods = Object.instance_methods , Kaltura::MediaEntry.instance_methods

  #clean out all the setter methods from the media entry methods
  valid_media_entry_methods = media_entry_methods.map{|m| m.to_sym unless m =~/^(.*)=/}.compact!

  valid_media_entry_methods -= object_methods
end