Module: KalturaFu::Entry::Metadata::ClassMethods
- Defined in:
- lib/kaltura_fu/entry/metadata/class_methods.rb
Instance Method Summary (collapse)
- - (Object) define_add_method(attr_name)
-
- (Object) define_attribute_methods
This method is called from with method_missing.
-
- (Object) define_get_method(attr_name)
defines a get methods.
-
- (Object) define_set_method(attr_name)
Defines the set method for a specific Media Entry attribute.
- - (Object) evaluate_attribute_method(attr_name, method_definition, method_name = attr_name)
-
- (Object) generated_methods
Contains the names of the generated attribute methods.
- - (Boolean) generated_methods?
Instance Method Details
- (Object) define_add_method(attr_name)
49 50 51 52 53 54 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 49 def define_add_method(attr_name) evaluate_attribute_method( attr_name, "def add_#{attr_name}(entry,new_value);add_attribute('#{attr_name}',entry,new_value);end", "add_#{attr_name}" ) end |
- (Object) define_attribute_methods
This method is called from with method_missing. It generates actual methods for all the valid Kaltura::Media Entry methods the first time a dynamic getter/setter/adder is called.
20 21 22 23 24 25 26 27 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 20 def define_attribute_methods return if generated_methods? valid_entry_attributes.each do |name| define_set_method(name) define_get_method(name) define_add_method(name) if valid_add_attribute?(name) end end |
- (Object) define_get_method(attr_name)
defines a get methods
42 43 44 45 46 47 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 42 def define_get_method(attr_name) evaluate_attribute_method( attr_name, "def get_#{attr_name}(entry);get_entry(entry).send('#{attr_name}');end", "get_#{attr_name}" ) end |
- (Object) define_set_method(attr_name)
Defines the set method for a specific Media Entry attribute
32 33 34 35 36 37 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 32 def define_set_method(attr_name) evaluate_attribute_method( attr_name, "def set_#{attr_name}(entry,new_value);set_attribute('#{attr_name}',entry,new_value);end", "set_#{attr_name}" ) end |
- (Object) evaluate_attribute_method(attr_name, method_definition, method_name = attr_name)
56 57 58 59 60 61 62 63 64 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 56 def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name) generated_methods << method_name begin class_eval(method_definition, __FILE__, __LINE__) rescue SyntaxError => err generated_methods.delete(attr_name) end end |
- (Object) generated_methods
Contains the names of the generated attribute methods.
7 8 9 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 7 def generated_methods #:nodoc: @generated_methods ||= Set.new end |
- (Boolean) generated_methods?
11 12 13 |
# File 'lib/kaltura_fu/entry/metadata/class_methods.rb', line 11 def generated_methods? !generated_methods.empty? end |