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

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

Instance Method Summary collapse

Instance Method Details

#entity_nameObject



48
49
50
# File 'foobara-0.1.7/projects/detached_entity/src/concerns/types.rb', line 48

def entity_name
  model_name
end

#entity_typeObject



10
11
12
13
14
15
16
17
18
# File 'foobara-0.1.7/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



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

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

#full_entity_nameObject



44
45
46
# File 'foobara-0.1.7/projects/detached_entity/src/concerns/types.rb', line 44

def full_entity_name
  full_model_name
end

#set_model_typeObject



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

def set_model_type
  if primary_key_attribute
    super
  end
end

#type_declarationObject



20
21
22
23
24
25
26
27
28
29
30
# File 'foobara-0.1.7/projects/detached_entity/src/concerns/types.rb', line 20

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

  declaration = super

  declaration[:type] = :detached_entity
  declaration[:primary_key] = primary_key_attribute
  declaration.is_absolutified = true

  declaration
end