Class: Vorpal::Config::BelongsToConfig

Inherits:
Object
  • Object
show all
Includes:
LocalEndConfig, Util::HashInitialization
Defined in:
lib/vorpal/config/belongs_to_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 LocalEndConfig

#associated_class_config, #fk_value, #set_foreign_key

Methods included from Util::HashInitialization

#initialize

Instance Attribute Details

#associated_classesObject (readonly)

Returns the value of attribute associated_classes.



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

def associated_classes
  @associated_classes
end

#association_configObject

Returns the value of attribute association_config.



20
21
22
# File 'lib/vorpal/config/belongs_to_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/belongs_to_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/belongs_to_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/belongs_to_config.rb', line 19

def name
  @name
end

#ownedObject (readonly)

Returns the value of attribute owned.



19
20
21
# File 'lib/vorpal/config/belongs_to_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/belongs_to_config.rb', line 19

def unique_key_name
  @unique_key_name
end

Instance Method Details

#associate(owner, associate) ⇒ Object



26
27
28
# File 'lib/vorpal/config/belongs_to_config.rb', line 26

def associate(owner, associate)
  owner.send("#{name}=", associate)
end

#get_associated(owner) ⇒ Object



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

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

#pretty_nameObject



30
31
32
# File 'lib/vorpal/config/belongs_to_config.rb', line 30

def pretty_name
  "#{association_config.local_class_config.domain_class.name} belongs_to :#{name}"
end