Class: DataMapper::Associations::ManyToOne::Proxy

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Assertions
Defined in:
lib/dm-core/associations/many_to_one.rb

Instance Method Summary collapse

Methods included from DataMapper::Assertions

#assert_kind_of

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



101
102
103
# File 'lib/dm-core/associations/many_to_one.rb', line 101

def method_missing(method, *args, &block)
  parent.__send__(method, *args, &block)
end

Instance Method Details

#instance_variable_get(variable) ⇒ Object



83
84
85
# File 'lib/dm-core/associations/many_to_one.rb', line 83

def instance_variable_get(variable)
  super || parent.instance_variable_get(variable)
end

#kind_of?(klass) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/dm-core/associations/many_to_one.rb', line 75

def kind_of?(klass)
  super || parent.kind_of?(klass)
end

#reloadObject



70
71
72
73
# File 'lib/dm-core/associations/many_to_one.rb', line 70

def reload
  @parent = nil
  self
end

#replace(parent) ⇒ Object



53
54
55
56
57
# File 'lib/dm-core/associations/many_to_one.rb', line 53

def replace(parent)
  @parent = parent
  @relationship.attach_parent(@child, @parent)
  self
end

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/dm-core/associations/many_to_one.rb', line 79

def respond_to?(method, include_private = false)
  super || parent.respond_to?(method, include_private)
end

#saveObject



59
60
61
62
63
64
65
66
67
68
# File 'lib/dm-core/associations/many_to_one.rb', line 59

def save
  return false if @parent.nil?
  return true  unless parent.new_record?

  @relationship.with_repository(parent) do
    result = parent.save
    @relationship.child_key.set(@child, @relationship.parent_key.get(parent)) if result
    result
  end
end