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, #clazz, #dirty, #json_name, #name

Instance Method Summary collapse

Methods inherited from Attribute

#dirty?, #from_hash, #mutable?, #read_only?, #to_hash

Constructor Details

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

Returns a new instance of BelongsToAttribute.



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

def initialize(name, actions, field_class, foreign_key, target_class_name)
  super(name, field_class, 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



9
10
11
# File 'lib/arrest/attributes/belongs_to_attribute.rb', line 9

def target_class
  @target_class ||= Arrest::Source.mod.const_get(@target_class_name)
end