Class: EntitySchema::Fields::FkBelongsTo

Inherits:
Property show all
Defined in:
lib/entity_schema/fields/fk_belongs_to.rb

Overview

Fk

Instance Attribute Summary collapse

Attributes inherited from Abstract

#name, #specification, #src_key

Instance Method Summary collapse

Methods inherited from Property

#get

Methods inherited from Abstract

#get, #given?, #public_get, #public_set, #serialize

Constructor Details

#initialize(options) ⇒ FkBelongsTo

Returns a new instance of FkBelongsTo.



11
12
13
14
15
# File 'lib/entity_schema/fields/fk_belongs_to.rb', line 11

def initialize(options)
  @name    = options[:fk]
  @src_key = options[:fk]
  super(options)
end

Instance Attribute Details

#observer_belongs_toObject

Returns the value of attribute observer_belongs_to.



9
10
11
# File 'lib/entity_schema/fields/fk_belongs_to.rb', line 9

def observer_belongs_to
  @observer_belongs_to
end

Instance Method Details

#set(obj, value, notify_observer: true) ⇒ Object



17
18
19
20
21
# File 'lib/entity_schema/fields/fk_belongs_to.rb', line 17

def set(obj, value, notify_observer: true)
  super(obj, value).tap do |fk|
    observer_belongs_to.fk_changed(fk, obj) if notify_observer
  end
end