Class: Context
- Inherits:
-
Object
- Object
- Context
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- app/models/context.rb
Overview
A context is the base class for any content or feature that can / is delivered by a deliverable. Each deliverable embeds many contexts within itself.
Additional context types should subclass Context
Direct Known Subclasses
Instance Method Summary (collapse)
- - (Object) as_json(options = {})
- - (Object) context_type
-
- (Object) set_default_position
On create, new contexts are added to the bottom of the 'stack'.
Instance Method Details
- (Object) as_json(options = {})
34 35 36 |
# File 'app/models/context.rb', line 34 def as_json( = {}) super().merge!(:id => self.id, :_type => self.context_type, :position => self.position) end |
- (Object) context_type
30 31 32 |
# File 'app/models/context.rb', line 30 def context_type self.class.name.to_s end |
- (Object) set_default_position
On create, new contexts are added to the bottom of the 'stack'. Contexts are always output in ascending order by their position.
26 27 28 |
# File 'app/models/context.rb', line 26 def set_default_position self.set('position', self._parent.contexts.count.to_i) end |