Class: PassiveRecord::Associations::BelongsToAssociation

Inherits:
Struct
  • Object
show all
Defined in:
lib/passive_record/associations/belongs_to.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#child_classObject

Returns the value of attribute child_class

Returns:

  • (Object)

    the current value of child_class



3
4
5
# File 'lib/passive_record/associations/belongs_to.rb', line 3

def child_class
  @child_class
end

#parent_class_nameObject

Returns the value of attribute parent_class_name

Returns:

  • (Object)

    the current value of parent_class_name



3
4
5
# File 'lib/passive_record/associations/belongs_to.rb', line 3

def parent_class_name
  @parent_class_name
end

#target_name_symbolObject

Returns the value of attribute target_name_symbol

Returns:

  • (Object)

    the current value of target_name_symbol



3
4
5
# File 'lib/passive_record/associations/belongs_to.rb', line 3

def target_name_symbol
  @target_name_symbol
end

Instance Method Details

#child_class_nameObject



16
17
18
# File 'lib/passive_record/associations/belongs_to.rb', line 16

def child_class_name
  child_class.name
end

#parent_classObject



8
9
10
11
12
13
14
# File 'lib/passive_record/associations/belongs_to.rb', line 8

def parent_class
  @parent_class ||= (
    module_name = child_class.name.deconstantize
    module_name = "Object" if module_name.empty?
    (module_name.constantize).const_get(parent_class_name)
  )
end

#to_relation(child_model) ⇒ Object



4
5
6
# File 'lib/passive_record/associations/belongs_to.rb', line 4

def to_relation(child_model)
  BelongsToRelation.new(self, child_model)
end