Class: RDFMapper::Associations::BelongsTo

Inherits:
Base
  • Object
show all
Defined in:
lib/lib/associations/belongs_to.rb

Overview

-

Instance Method Summary collapse

Methods inherited from Base

#initialize, #inspect, #object, #to_statements

Methods included from Logger

#debug, #fatal, #warn

Constructor Details

This class inherits a constructor from RDFMapper::Associations::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RDFMapper::Associations::Base

Instance Method Details

#idObject

-


11
12
13
# File 'lib/lib/associations/belongs_to.rb', line 11

def id
  value.id
end

#keysObject

Returns the ‘foreign key’ (i.e. association URI).



49
50
51
# File 'lib/lib/associations/belongs_to.rb', line 49

def keys
  @key || value.id
end

#kind_of?(type) ⇒ Boolean

-

Returns:

  • (Boolean)


25
26
27
# File 'lib/lib/associations/belongs_to.rb', line 25

def kind_of?(type)
  value.kind_of?(type)
end

#nil?Boolean

-

Returns:

  • (Boolean)


18
19
20
# File 'lib/lib/associations/belongs_to.rb', line 18

def nil?
  value.nil?
end

#replace(value) ⇒ Object

Replaces current association with a new object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/lib/associations/belongs_to.rb', line 32

def replace(value)
  if value.kind_of? String
    @key = RDF::URI.new(value)
  end
  if value.kind_of? RDF::URI
    @key = value
  end
  if value.kind_of? RDFMapper::Model
    @value = value
  else
    nil
  end
end