Class: ODM::Classes
- Inherits:
-
Object
show all
- Defined in:
- lib/odm.rb
Instance Method Summary
collapse
Constructor Details
#initialize(*args, &block) ⇒ Classes
Returns a new instance of Classes.
82
83
84
85
86
87
88
89
|
# File 'lib/odm.rb', line 82
def initialize *args, &block
@class_levels= args.select{|e|(e.class <= Hash)}.select{|hsh|(hsh.keys - ODM::CoreClasses.map{|e|e.to_s.downcase.to_sym}).empty?}
@block= block
__block__
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
67
68
69
|
# File 'lib/odm.rb', line 67
def method_missing *args
return nil
end
|
Instance Method Details
#__block__ ⇒ Object
63
64
65
|
# File 'lib/odm.rb', line 63
def __block__
@block.call(self) unless @block.nil?
end
|
#__default__ ⇒ Object
58
59
60
61
|
# File 'lib/odm.rb', line 58
def __default__
ODM::CoreClasses.each{ |klass| self.instance_variable_set( "@#{klass.to_s.downcase}", nil ) }
__block__
end
|
#class_leveler(level) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/odm.rb', line 71
def class_leveler(level)
self.__default__
unless @class_levels.empty?
unless @class_levels[level].nil?
@class_levels[level].each{|from_class,to_class| self.__send__( "#{from_class}=",to_class) }
end
end
end
|