Class: SimpleMaster::Master::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_master/master/association.rb,
lib/simple_master/master/association/has_one_association.rb,
lib/simple_master/master/association/has_many_association.rb,
lib/simple_master/master/association/belongs_to_association.rb,
lib/simple_master/master/association/has_many_through_association.rb,
lib/simple_master/master/association/belongs_to_polymorphic_association.rb

Defined Under Namespace

Classes: BelongsToAssociation, BelongsToPolymorphicAssociation, HasManyAssociation, HasManyThroughAssociation, HasOneAssociation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master_class, name, options) ⇒ Association

Returns a new instance of Association.



16
17
18
19
20
# File 'lib/simple_master/master/association.rb', line 16

def initialize(master_class, name, options)
  @name = name
  @defined_at = master_class
  @options = options
end

Instance Attribute Details

#defined_atObject (readonly)

Returns the value of attribute defined_at.



13
14
15
# File 'lib/simple_master/master/association.rb', line 13

def defined_at
  @defined_at
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/simple_master/master/association.rb', line 12

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/simple_master/master/association.rb', line 14

def options
  @options
end

Instance Method Details

#init(master_class) ⇒ Object



31
32
# File 'lib/simple_master/master/association.rb', line 31

def init(master_class)
end

#init_for_test(master_class) ⇒ Object



34
35
# File 'lib/simple_master/master/association.rb', line 34

def init_for_test(master_class)
end

#is_active_record?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/simple_master/master/association.rb', line 27

def is_active_record?
  target_class < ::ActiveRecord::Base
end

#target_classObject

Execute after definition phase.



23
24
25
# File 'lib/simple_master/master/association.rb', line 23

def target_class
  @target_class ||= find_class(defined_at, options[:class_name] || ActiveSupport::Inflector.classify(name))
end