Module: Foobara::DetachedEntity::Concerns::Types::ClassMethods

Defined in:
foobara-0.0.110/projects/detached_entity/src/concerns/types.rb

Instance Method Summary collapse

Instance Method Details

#entity_nameObject



42
43
44
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 42

def entity_name
  model_name
end

#entity_typeObject



10
11
12
13
14
15
16
17
18
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 10

def entity_type
  return @model_type if defined?(@model_type)

  if attributes_type
    set_model_type
  end

  @model_type
end

#foobara_primary_key_typeObject Also known as: primary_key_type



32
33
34
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 32

def foobara_primary_key_type
  @foobara_primary_key_type ||= attributes_type.element_types[primary_key_attribute]
end

#full_entity_nameObject



38
39
40
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 38

def full_entity_name
  full_model_name
end

#set_model_typeObject



26
27
28
29
30
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 26

def set_model_type
  if primary_key_attribute
    super
  end
end

#type_declarationObject



20
21
22
23
24
# File 'foobara-0.0.110/projects/detached_entity/src/concerns/types.rb', line 20

def type_declaration(...)
  raise "No primary key set yet" unless primary_key_attribute

  super.merge(type: :detached_entity, primary_key: primary_key_attribute)
end