Class: ViewModel::Reference
- Inherits:
-
Object
- Object
- ViewModel::Reference
- Defined in:
- lib/view_model/reference.rb
Overview
Key to identify a viewmodel with some kind of inherent ID (e.g. an ViewModel::ActiveRecord)
Instance Attribute Summary collapse
-
#model_id ⇒ Object
Returns the value of attribute model_id.
-
#viewmodel_class ⇒ Object
Returns the value of attribute viewmodel_class.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(viewmodel_class, model_id) ⇒ Reference
constructor
A new instance of Reference.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(viewmodel_class, model_id) ⇒ Reference
Returns a new instance of Reference.
6 7 8 9 |
# File 'lib/view_model/reference.rb', line 6 def initialize(viewmodel_class, model_id) @viewmodel_class = viewmodel_class @model_id = model_id end |
Instance Attribute Details
#model_id ⇒ Object
Returns the value of attribute model_id.
4 5 6 |
# File 'lib/view_model/reference.rb', line 4 def model_id @model_id end |
#viewmodel_class ⇒ Object
Returns the value of attribute viewmodel_class.
4 5 6 |
# File 'lib/view_model/reference.rb', line 4 def viewmodel_class @viewmodel_class end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
19 20 21 22 23 |
# File 'lib/view_model/reference.rb', line 19 def ==(other) other.class == self.class && other.viewmodel_class == viewmodel_class && other.model_id == model_id end |
#hash ⇒ Object
27 28 29 |
# File 'lib/view_model/reference.rb', line 27 def hash [viewmodel_class, model_id].hash end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/view_model/reference.rb', line 15 def inspect "<Ref:#{self}>" end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/view_model/reference.rb', line 11 def to_s "'#{viewmodel_class.view_name}(id=#{model_id})'" end |