Class: Tempo::Views::ViewRecords::Model
- Inherits:
-
Object
- Object
- Tempo::Views::ViewRecords::Model
- Defined in:
- lib/tempo/views/view_records/base.rb
Overview
Base model class, used for extending views for any child of Tempo::Model::Base Sets the id, and type, where type is the class type of the model, for example “project” for Tempo::Model::Project. ViewReord::Model should handle any type of tempo model without error, but most likely won’t be as useful as a child class taylored to the specifics of the actual model’s child class.
Containers send :pospone => true in options in order to manage triggering the message themselves
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #format(&block) ⇒ Object
-
#initialize(model, options = {}) ⇒ Model
constructor
A new instance of Model.
Constructor Details
#initialize(model, options = {}) ⇒ Model
Returns a new instance of Model.
129 130 131 132 133 134 135 |
# File 'lib/tempo/views/view_records/base.rb', line 129 def initialize(model, ={}) @id = model.id # example: Tempo::Model::Something => "something" @type = /Tempo::Model::(.*)$/.match( model.class.to_s )[1].downcase Reporter.add_view_record self unless [:postpone] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
127 128 129 |
# File 'lib/tempo/views/view_records/base.rb', line 127 def id @id end |
#type ⇒ Object
Returns the value of attribute type.
127 128 129 |
# File 'lib/tempo/views/view_records/base.rb', line 127 def type @type end |
Instance Method Details
#format(&block) ⇒ Object
137 138 139 140 |
# File 'lib/tempo/views/view_records/base.rb', line 137 def format(&block) block ||= lambda {|model| "#{ model.type.capitalize} #{model.id}"} block.call self end |