Sha256: d4ed94e9e81876370326430642ccb748d9a6dc8e6eb55962f0cf45ef314ef4c6

Contents?: true

Size: 1.76 KB

Versions: 3

Compression:

Stored size: 1.76 KB

Contents

module KalturaBox
  module Entry
    module Metadata

      ##
      # 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.
      ##
      module ClassAndInstanceMethods

        ##
        # Checks if a requested attribute is in fact a valid MediaEntry atrribute.
        ##
        def valid_entry_attribute?(request_attribute)
          object_methods, media_entry_methods = Object.instance_methods , Kaltura::KalturaMediaEntry.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

        ##
        # @private
        ##
        def valid_entry_attributes
          object_methods, media_entry_methods = Object.instance_methods , Kaltura::KalturaMediaEntry.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
        ##
        # Determines if an attribute is valid in the sense of the add method making sense.  Only
        # categories and tags are currently considered valid.
        ##
        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

      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaltura_box-0.0.3 lib/kaltura_box/entry/metadata/class_and_instance_methods.rb
kaltura_box-0.0.2 lib/kaltura_box/entry/metadata/class_and_instance_methods.rb
kaltura_box-0.0.1 lib/kaltura_box/entry/metadata/class_and_instance_methods.rb