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.
74
75
76
77
78
79
80
81
|
# File 'lib/odm.rb', line 74
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
59
60
61
|
# File 'lib/odm.rb', line 59
def method_missing *args
return nil
end
|
Instance Method Details
#__block__ ⇒ Object
55
56
57
|
# File 'lib/odm.rb', line 55
def __block__
@block.call(self) unless @block.nil?
end
|
#__default__ ⇒ Object
50
51
52
53
|
# File 'lib/odm.rb', line 50
def __default__
ODM::CoreClasses.each{ |klass| self.instance_variable_set( "@#{klass.to_s.downcase}", nil ) }
__block__
end
|
#class_leveler(level) ⇒ Object
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/odm.rb', line 63
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
|