Class: Arrest::BelongsToAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/arrest/attributes/belongs_to_attribute.rb

Instance Attribute Summary collapse

Attributes inherited from Attribute

#actions, #dirty, #json_name, #name

Instance Method Summary collapse

Methods inherited from Attribute

#clazz, #clazz=, #dirty?, #dirty_sensitive?, #from_hash, #mutable?, #read_only?, #to_hash

Constructor Details

#initialize(name, actions, field_class_name, foreign_key, target_class_name) ⇒ BelongsToAttribute

Returns a new instance of BelongsToAttribute.



5
6
7
8
9
# File 'lib/arrest/attributes/belongs_to_attribute.rb', line 5

def initialize(name, actions, field_class_name, foreign_key, target_class_name)
  super(name, field_class_name, actions)
  @foreign_key = foreign_key
  @target_class_name = target_class_name
end

Instance Attribute Details

#foreign_keyObject

Returns the value of attribute foreign_key.



3
4
5
# File 'lib/arrest/attributes/belongs_to_attribute.rb', line 3

def foreign_key
  @foreign_key
end

Instance Method Details

#target_classObject



11
12
13
# File 'lib/arrest/attributes/belongs_to_attribute.rb', line 11

def target_class
  @target_class ||= Arrest::Source.class_loader.load(@target_class_name)
end