Class: KDomain::DomainModel::HasOne

Inherits:
Object
  • Object
show all
Defined in:
lib/k_domain/schemas/domain/old/has_one.rb

Constant Summary collapse

KEYS =

KEYS = [:model_name, :model_name_plural, :a_lambda, :class_name, :foreign_key, :primary_key, :infer_key]

%i[a_lambda class_name foreign_key primary_key infer_key code_duplicate].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#a_lambdaObject

Returns the value of attribute a_lambda.



14
15
16
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 14

def a_lambda
  @a_lambda
end

#class_nameObject

Returns the value of attribute class_name.



15
16
17
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 15

def class_name
  @class_name
end

#code_duplicateObject

Returns the value of attribute code_duplicate.



24
25
26
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 24

def code_duplicate
  @code_duplicate
end

#foreign_keyObject

Returns the value of attribute foreign_key.



16
17
18
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 16

def foreign_key
  @foreign_key
end

#model_nameObject

Returns the value of attribute model_name.



11
12
13
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 11

def model_name
  @model_name
end

#model_name_pluralObject

Returns the value of attribute model_name_plural.



12
13
14
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 12

def model_name_plural
  @model_name_plural
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 9

def name
  @name
end

#primary_keyObject

Returns the value of attribute primary_key.



17
18
19
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 17

def primary_key
  @primary_key
end

Returns the value of attribute related_entity.



23
24
25
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 23

def related_entity
  @related_entity
end

Instance Method Details

#infer_keyObject



19
20
21
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 19

def infer_key
  primary_key.nil? ? "#{name}_id" : primary_key
end

#to_hObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/k_domain/schemas/domain/old/has_one.rb', line 26

def to_h
  {
    name: name,
    model_name: model_name,
    model_name_plural: model_name_plural,
    a_lambda: a_lambda,
    class_name: class_name,
    foreign_key: foreign_key,
    primary_key: primary_key,
    code_duplicate: code_duplicate,
    related_entity: related_entity.to_h
  }
end