Class: RDFMapper::Associations::BelongsTo
- Defined in:
- lib/lib/associations/belongs_to.rb
Overview
- -
Instance Method Summary collapse
-
#id ⇒ Object
[-].
-
#keys ⇒ Object
Returns the ‘foreign key’ (i.e. association URI).
-
#kind_of?(type) ⇒ Boolean
[-].
-
#nil? ⇒ Boolean
[-].
-
#replace(value) ⇒ Object
Replaces current association with a new object.
Methods inherited from Base
#initialize, #inspect, #object, #to_statements
Methods included from Logger
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
#id ⇒ Object
- -
11 12 13 |
# File 'lib/lib/associations/belongs_to.rb', line 11 def id value.id end |
#keys ⇒ Object
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
- -
25 26 27 |
# File 'lib/lib/associations/belongs_to.rb', line 25 def kind_of?(type) value.kind_of?(type) end |
#nil? ⇒ 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 |