Class: Vorpal::Config::HasManyConfig

Inherits:
Object
  • Object
show all
Includes:
RemoteEndConfig, Util::HashInitialization
Defined in:
lib/vorpal/config/has_many_config.rb

Overview

Object association terminology:

  • All object associations are uni-directional

  • The end that holds the association is the ‘Owner’ and the end that is referred to is the ‘Associate’ or ‘Associates’

Relational association terminology:

  • Local end: has FK

  • Remote end: has no FK

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RemoteEndConfig

#associated_class_config, #foreign_key_info, #get_unique_key_value, #set_class_config, #set_foreign_key

Methods included from Util::HashInitialization

#initialize

Instance Attribute Details

#associated_classObject (readonly)

Returns the value of attribute associated_class.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def associated_class
  @associated_class
end

#association_configObject

Returns the value of attribute association_config.



20
21
22
# File 'lib/vorpal/config/has_many_config.rb', line 20

def association_config
  @association_config
end

#fkObject (readonly)

Returns the value of attribute fk.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def fk
  @fk
end

#fk_typeObject (readonly)

Returns the value of attribute fk_type.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def fk_type
  @fk_type
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def name
  @name
end

#ownedObject (readonly)

Returns the value of attribute owned.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def owned
  @owned
end

#unique_key_nameObject (readonly)

Returns the value of attribute unique_key_name.



19
20
21
# File 'lib/vorpal/config/has_many_config.rb', line 19

def unique_key_name
  @unique_key_name
end

Instance Method Details

#associate(owner, associates) ⇒ Object



26
27
28
29
30
31
# File 'lib/vorpal/config/has_many_config.rb', line 26

def associate(owner, associates)
  if get_associated(owner).nil?
    owner.send("#{name}=", [])
  end
  get_associated(owner) << associates
end

#get_associated(owner) ⇒ Object



22
23
24
# File 'lib/vorpal/config/has_many_config.rb', line 22

def get_associated(owner)
  owner.send(name)
end

#pretty_nameObject



33
34
35
# File 'lib/vorpal/config/has_many_config.rb', line 33

def pretty_name
  "#{@class_config.domain_class.name} has_many :#{name}"
end