Class: Ephemeral::Relation
- Inherits:
-
Object
- Object
- Ephemeral::Relation
- Defined in:
- lib/ephemeral/relation.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(klass, object = nil) ⇒ Relation
constructor
A new instance of Relation.
- #materialize(object = nil) ⇒ Object
Constructor Details
#initialize(klass, object = nil) ⇒ Relation
Returns a new instance of Relation.
7 8 9 10 11 |
# File 'lib/ephemeral/relation.rb', line 7 def initialize(klass, object=nil) self.klass = klass self.object = self.materialize(object) self end |
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
5 6 7 |
# File 'lib/ephemeral/relation.rb', line 5 def klass @klass end |
#object ⇒ Object
Returns the value of attribute object.
5 6 7 |
# File 'lib/ephemeral/relation.rb', line 5 def object @object end |
Instance Method Details
#materialize(object = nil) ⇒ Object
13 14 15 16 17 |
# File 'lib/ephemeral/relation.rb', line 13 def materialize(object=nil) return nil unless object return object if object.class.name == self.klass eval(self.klass).new(object) end |