Class: Foobara::Entity

Inherits:
DetachedEntity show all
Extended by:
NewPrepend
Includes:
Concerns::Attributes, Concerns::Callbacks, Concerns::Initialization, Concerns::Mutations, Concerns::Persistence, Concerns::Queries, Concerns::Transactions, Concerns::Types
Defined in:
foobara-0.5.8/projects/entities/projects/entity/lib/foobara/entity.rb,
foobara-0.5.8/projects/entities/projects/entity/src/entity.rb,
foobara-0.5.8/projects/entities/projects/entity/src/new_prepend.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/types.rb,
foobara-0.5.8/projects/entities/projects/entity/src/not_found_error.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/queries.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/callbacks.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/mutations.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/attributes.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/persistence.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/transactions.rb,
foobara-0.5.8/projects/entities/projects/entity/src/concerns/initialization.rb,
foobara-0.5.8/projects/entities/projects/entity/src/sensitive_type_removers/entity.rb,
foobara-0.5.8/projects/entities/projects/entity/src/sensitive_value_removers/entity.rb

Overview

TODO: I think we should have a configuration that indicates if created records can have primary keys passed to them or not. That is, do primary keys get issued by the database upon insertion? Or are they generated externally and passed in? Would be nice to have programmatic clarification via explicit configuration.

Defined Under Namespace

Modules: Concerns, NewPrepend, SensitiveTypeRemovers, SensitiveValueRemovers Classes: NoCurrentTransactionError, NotFoundError

Constant Summary

Constants included from DetachedEntity::Concerns::Initialization

DetachedEntity::Concerns::Initialization::ALLOWED_OPTIONS

Constants inherited from Model

Model::ALLOWED_OPTIONS

Instance Attribute Summary

Attributes included from Concerns::Persistence

#is_built, #is_created, #is_hard_deleted, #is_persisted, #persisted_attributes

Attributes included from Concerns::Callbacks

#callback_registry

Attributes included from DetachedEntity::Concerns::Persistence

#is_loaded

Attributes inherited from Model

#mutable, #skip_validations

Class Method Summary collapse

Methods included from NewPrepend

__private_new__, new

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Methods included from Concerns::Initialization

#build, #successfully_loaded

Methods included from Concerns::Persistence

#built?, #created?, #dirty?, #hard_delete!, #hard_delete_without_callbacks!, #hard_deleted?, #load_if_necessary!, #persisted?, #restore!, #restore_without_callbacks!, #save_persisted_attributes, #to_persisted_attributes, #unhard_delete!, #verify_not_hard_deleted!

Methods included from Concerns::Attributes

#can_read_attributes_other_than_primary_key?, #read_attribute, #read_attribute!, #values_at, #with_changed_attribute_callbacks, #write_attribute, #write_attribute!, #write_attribute_without_callbacks, #write_attribute_without_callbacks!, #write_attributes, #write_attributes_without_callbacks

Methods included from Concerns::Mutations

#update, #update_aggregate

Methods included from Concerns::Callbacks

#fire, #initialize, #register_callback, #without_callbacks

Methods included from DetachedEntity::Concerns::Initialization

#initialize

Methods included from DetachedEntity::Concerns::Serialize

#inspect, #to_json

Methods included from DetachedEntity::Concerns::Types

#entity_name, #full_entity_name

Methods included from DetachedEntity::Concerns::PrimaryKey

#primary_key, #primary_key_attribute

Methods included from DetachedEntity::Concerns::Equality

#==, #dup, #hash

Methods included from DetachedEntity::Concerns::Persistence

#loaded?

Methods included from DetachedEntity::Concerns::Attributes

#can_read_attributes_other_than_primary_key?, #read_attribute

Methods inherited from Model

#==, abstract, abstract?, attribute_names, #attributes, #attributes_with_delegates, #cast_attribute, #cast_attribute!, closest_namespace_module, description, domain, domain_name, #eql?, fire_reregistered!, foobara_model_name, foobara_name, full_model_name, #hash, #initialize, #model_name, on_reregister, organization_name, possible_errors, #read_attribute, #read_attribute!, subclass, #to_h, #to_json, #valid?, valid_attribute_name?, #valid_attribute_name?, #validate!, validate_attribute_name!, #validate_attribute_name!, #validation_errors, #write_attribute, #write_attribute!, #write_attributes, #write_attributes!

Methods included from Model::Concerns::Types

#attributes_type

Class Method Details

.install!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'projects/entities/projects/entity/lib/foobara/entity.rb', line 11

def install!
  handler = TypeDeclarations::Handlers::ExtendEntityTypeDeclaration.new
  TypeDeclarations.register_type_declaration(handler)

  TypeDeclarations.register_sensitive_type_remover(SensitiveTypeRemovers::Entity.new(handler))
  TypeDeclarations.register_sensitive_value_remover(handler, SensitiveValueRemovers::Entity)

  detached_entity = Namespace.global.foobara_lookup_type!(:detached_entity)
  BuiltinTypes.build_and_register!(:entity, detached_entity, nil)

  DetachedEntityType.types_requiring_conversion << :entity
  DetachedEntityType.model_base_classes_requiring_conversion << "Foobara::Entity"
end

.reset_allObject



25
26
27
28
29
30
# File 'projects/entities/projects/entity/lib/foobara/entity.rb', line 25

def reset_all
  Foobara.raise_if_production!("reset_all")
  Entity::Concerns::Callbacks.reset_all

  install!
end