Module: Maestrano::Connector::Rails::Concerns::SubEntityBase::ClassMethods

Defined in:
app/models/maestrano/connector/rails/concerns/sub_entity_base.rb

Instance Method Summary collapse

Instance Method Details

#connec_entity_nameObject



21
22
23
24
25
26
27
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 21

def connec_entity_name
  if external?
    raise "Forbidden call: cannot call connec_entity_name for an external entity"
  else
    entity_name
  end
end

#create_idmap_from_connec_entity(entity, external_entity_name, organization) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 51

def create_idmap_from_connec_entity(entity, external_entity_name, organization)
  if external?
    raise 'Forbidden call: cannot call create_idmap_from_connec_entity for an external entity'
  else
    h = names_hash.merge({
      connec_id: entity['id'],
      name: object_name_from_connec_entity_hash(entity),
      external_entity: external_entity_name.downcase,
      organization_id: organization.id
    })
    Maestrano::Connector::Rails::IdMap.create(h)
  end
end

#create_idmap_from_external_entity(entity, connec_entity_name, organization) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 37

def create_idmap_from_external_entity(entity, connec_entity_name, organization)
  if external?
    h = names_hash.merge({
      external_id: id_from_external_entity_hash(entity),
      name: object_name_from_external_entity_hash(entity),
      connec_entity: connec_entity_name.downcase,
      organization_id: organization.id
    })
    Maestrano::Connector::Rails::IdMap.create(h)
  else
    raise 'Forbidden call: cannot call create_idmap_from_external_entity for a connec entity'
  end
end

#entity_nameObject



9
10
11
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 9

def entity_name
  raise "Not implemented"
end

#external?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 5

def external?
  raise "Not implemented"
end

#external_entity_nameObject



13
14
15
16
17
18
19
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 13

def external_entity_name
  if external?
    entity_name
  else
    raise "Forbidden call: cannot call external_entity_name for a connec entity"
  end
end

#mapper_classesObject

{ ‘External Entity’ => LalaMapper, ‘Other external entity’ => LiliMapper } or { ‘Connec Entity’ => LalaMapper, ‘Other connec entity’ => LiliMapper }



67
68
69
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 67

def mapper_classes
  {}
end

#names_hashObject



29
30
31
32
33
34
35
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 29

def names_hash
  if external?
    {external_entity: entity_name.downcase}
  else
    {connec_entity: entity_name.downcase}
  end
end

#referencesObject

'External Entity' => [{reference_class: Entities::.., connec_field: '', external_field: ''],
'Other external entity' => [Entities::.., connec_field: '', external_field: '']

}



75
76
77
# File 'app/models/maestrano/connector/rails/concerns/sub_entity_base.rb', line 75

def references
  {}
end