Class: Rod::AbstractModel
- Inherits:
-
Object
- Object
- Rod::AbstractModel
- Defined in:
- lib/rod/abstract_model.rb
Overview
A base class for all classes stored in the DataBase (both user defined and DB defined).
Direct Known Subclasses
Class Method Summary (collapse)
-
+ (Object) build_structure
By default nothing is built.
-
+ (Object) cache
Default cache for models.
-
+ (Boolean) compatible?(metadata)
Checks if the metadata are compatible with the class definition.
-
+ (Object) difference(metadata)
Calculates the difference between the classes metadata and the metadata provided.
-
+ (Object) fields
By default there are no fields.
-
+ (Object) indexed_properties
There are no indexed properties.
-
+ (Object) layout
Default implementation prints nothing.
-
+ (Object) metadata
Returns meta-data (in the form of a hash) for the model.
-
+ (Object) path_for_data(path)
Path to the file storing the model data.
-
+ (Object) properties
By default properties are empty.
-
+ (Object) struct_name
C-struct name of the model.
-
+ (Object) typedef_struct
Empty string.
Class Method Details
+ (Object) build_structure
By default nothing is built.
30 31 |
# File 'lib/rod/abstract_model.rb', line 30 def self.build_structure end |
+ (Object) cache
Default cache for models.
34 35 36 |
# File 'lib/rod/abstract_model.rb', line 34 def self.cache @cache ||= Cache.new end |
+ (Boolean) compatible?(metadata)
Checks if the metadata are compatible with the class definition.
56 57 58 |
# File 'lib/rod/abstract_model.rb', line 56 def self.compatible?() self.difference().empty? end |
+ (Object) difference(metadata)
Calculates the difference between the classes metadata and the metadata provided.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rod/abstract_model.rb', line 62 def self.difference() = self. = .dup .delete(:count) result = [] .each do |type,values| # TODO #161 the order of properties should be preserved for the # whole class, not only for each type of properties. if [:fields,:has_one,:has_many].include?(type) values.to_a.zip([type].to_a) do |,| if != result << [,] end end else if [type] != values result << [[type],values] end end end result end |
+ (Object) fields
By default there are no fields.
25 26 27 |
# File 'lib/rod/abstract_model.rb', line 25 def self.fields [] end |
+ (Object) indexed_properties
There are no indexed properties.
39 40 41 |
# File 'lib/rod/abstract_model.rb', line 39 def self.indexed_properties [] end |
+ (Object) layout
Default implementation prints nothing.
21 22 |
# File 'lib/rod/abstract_model.rb', line 21 def self.layout end |
+ (Object) metadata
Returns meta-data (in the form of a hash) for the model.
49 50 51 52 53 |
# File 'lib/rod/abstract_model.rb', line 49 def self. = {} [:superclass] = self.superclass.name end |
+ (Object) path_for_data(path)
Path to the file storing the model data.
16 17 18 |
# File 'lib/rod/abstract_model.rb', line 16 def self.path_for_data(path) "#{path}#{self.struct_name}.dat" end |
+ (Object) properties
By default properties are empty.
44 45 46 |
# File 'lib/rod/abstract_model.rb', line 44 def self.properties [] end |
+ (Object) struct_name
C-struct name of the model.
11 12 13 |
# File 'lib/rod/abstract_model.rb', line 11 def self.struct_name raise RodException.new("#typdef_struct called for AbstractModel") end |
+ (Object) typedef_struct
Empty string.
6 7 8 |
# File 'lib/rod/abstract_model.rb', line 6 def self.typedef_struct raise RodException.new("#typdef_struct called for AbstractModel") end |