Class: ArtirixDataModels::ModelFieldsDAO

Inherits:
Object
  • Object
show all
Includes:
WithDAORegistry
Defined in:
lib/artirix_data_models/daos/model_fields_dao.rb

Overview

DAO responsible for checking the fields list in both FULL and PARTIAL modes for a given model name.

It does so accessing the “fields list” entry point via the DataGateway

The Information should not change so it is stored in a constant Hash, so it’ll be accessed only once for each model and type

Constant Summary collapse

PARTIAL_FIELDS =
{}

Constants included from WithDAORegistry

WithDAORegistry::DEFAULT_DAO_REGISTRY_LOADER

Instance Attribute Summary

Attributes included from WithDAORegistry

#dao_registry_loader

Instance Method Summary collapse

Methods included from WithDAORegistry

#dao_registry, #dao_registry=, #default_dao_registry, loader_or_registry_or_default, #set_dao_registry, #set_dao_registry_and_loader, #set_dao_registry_loader, #set_default_dao_registry_loader

Constructor Details

#initialize(dao_registry: nil, dao_registry_loader: nil, gateway: nil) ⇒ ModelFieldsDAO

Returns a new instance of ModelFieldsDAO.



12
13
14
15
# File 'lib/artirix_data_models/daos/model_fields_dao.rb', line 12

def initialize(dao_registry: nil, dao_registry_loader: nil, gateway: nil)
  set_dao_registry_and_loader dao_registry_loader, dao_registry
  @gateway = gateway
end

Instance Method Details

#gatewayObject



17
18
19
# File 'lib/artirix_data_models/daos/model_fields_dao.rb', line 17

def gateway
  @gateway ||= dao_registry.gateway
end

#partial_mode_fields_for(model_name) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/artirix_data_models/daos/model_fields_dao.rb', line 21

def partial_mode_fields_for(model_name)
  model_name = model_name.to_s

  PARTIAL_FIELDS.fetch(model_name) do
    PARTIAL_FIELDS[model_name] = _get_partial model_name
  end
end