Class: Ephemeral::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/ephemeral/relation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#klassObject

Returns the value of attribute klass.



5
6
7
# File 'lib/ephemeral/relation.rb', line 5

def klass
  @klass
end

#objectObject

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