Class: Historical::ClassBuilder
- Inherits:
-
Object
- Object
- Historical::ClassBuilder
- Defined in:
- lib/historical/class_builder.rb
Overview
Builds the customized classes for a record.
Instance Attribute Summary collapse
-
#callbacks ⇒ Array<Proc>
A list of callbacks to be evaluated on save.
-
#diff_class ⇒ Class
A customized subclass of Models::ModelVersion::Diff.
-
#meta_class ⇒ Class
A customized subclass of Models::ModelVersion::Meta.
-
#version_class ⇒ Class
A customized subclass of Models::ModelVersion.
Builder Methods collapse
-
#callback {|version| ... } ⇒ Object
A callback to be called when a new version is spawned (i.e. model was saved with changes).
-
#meta(&block) ⇒ Object
Evaluated within class scope of the custom Models::ModelVersion::Meta for this record.
Instance Method Summary collapse
-
#initialize(base) ⇒ ClassBuilder
constructor
A new instance of ClassBuilder.
Constructor Details
#initialize(base) ⇒ ClassBuilder
Returns a new instance of ClassBuilder.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/historical/class_builder.rb', line 21 def initialize(base) self.callbacks = [] self.version_class = Historical::Models::ModelVersion.for_class(base) self.diff_class = Historical::Models::ModelVersion::Diff.for_class(base) self. = Historical::Models::ModelVersion::Meta.for_class(base) base.historical_customizations.each do |customization| instance_eval(&customization) end end |
Instance Attribute Details
#callbacks ⇒ Array<Proc>
Returns A list of callbacks to be evaluated on save.
6 7 8 |
# File 'lib/historical/class_builder.rb', line 6 def callbacks @callbacks end |
#diff_class ⇒ Class
Returns A customized subclass of Models::ModelVersion::Diff.
14 15 16 |
# File 'lib/historical/class_builder.rb', line 14 def diff_class @diff_class end |
#meta_class ⇒ Class
Returns A customized subclass of Models::ModelVersion::Meta.
10 11 12 |
# File 'lib/historical/class_builder.rb', line 10 def @meta_class end |
#version_class ⇒ Class
Returns A customized subclass of Models::ModelVersion.
18 19 20 |
# File 'lib/historical/class_builder.rb', line 18 def version_class @version_class end |
Instance Method Details
#callback {|version| ... } ⇒ Object
A callback to be called when a new version is spawned (i.e. model was saved with changes)
56 57 58 |
# File 'lib/historical/class_builder.rb', line 56 def callback(&block) self.callbacks << block end |
#meta(&block) ⇒ Object
Evaluated within class scope of the custom Models::ModelVersion::Meta for this record. The Meta-class includes ‘MongoMapper::EmbeddedDocument` and MongoMapperEnhancements.
43 44 45 |
# File 'lib/historical/class_builder.rb', line 43 def (&block) .instance_eval(&block) end |