Parent

Class Index [+]

Quicksearch

DataMapper::Associations::OneToOne::Relationship

Attributes

relationship[R]

Public Class Methods

new(name, target_model, source_model, options = {}) click to toggle source

Initializes the relationship. Always assumes target model class is a camel cased association name.

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 73
73:         def initialize(name, target_model, source_model, options = {})
74:           klass = options.key?(:through) ? ManyToMany::Relationship : OneToMany::Relationship
75:           target_model ||= DataMapper::Inflector.camelize(name).freeze
76:           @relationship = klass.new(name, target_model, source_model, options)
77:         end

Public Instance Methods

default_for(source) click to toggle source

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 46
46:         def default_for(source)
47:           relationship.default_for(source).first
48:         end
get(source, query = nil) click to toggle source

Loads (if necessary) and returns association target for given source

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 18
18:         def get(source, query = nil)
19:           relationship.get(source, query).first
20:         end
get!(source) click to toggle source

Get the resource directly

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 25
25:         def get!(source)
26:           collection = relationship.get!(source)
27:           collection.first if collection
28:         end
instance_of?(klass) click to toggle source

@api public

    # File lib/dm-core/associations/one_to_one.rb, line 56
56:         def instance_of?(klass)
57:           super || relationship.instance_of?(klass)
58:         end
kind_of?(klass) click to toggle source

@api public

    # File lib/dm-core/associations/one_to_one.rb, line 51
51:         def kind_of?(klass)
52:           super || relationship.kind_of?(klass)
53:         end
respond_to?(method, include_private = false) click to toggle source

@api public

    # File lib/dm-core/associations/one_to_one.rb, line 61
61:         def respond_to?(method, include_private = false)
62:           super || relationship.respond_to?(method, include_private)
63:         end
set(source, target) click to toggle source

Sets and returns association target for given source

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 34
34:         def set(source, target)
35:           relationship.set(source, [ target ].compact).first
36:         end
set!(source, target) click to toggle source

Sets the resource directly

@api semipublic

    # File lib/dm-core/associations/one_to_one.rb, line 41
41:         def set!(source, target)
42:           set(source, target)
43:         end

Private Instance Methods

method_missing(method, *args, &block) click to toggle source

@api private

    # File lib/dm-core/associations/one_to_one.rb, line 80
80:         def method_missing(method, *args, &block)
81:           relationship.send(method, *args, &block)
82:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.