Class: Appfuel::Db::ActiveRecordModel

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Application::AppContainer
Defined in:
lib/appfuel/storage/db/active_record_model.rb

Overview

ActiveRecord::Base that auto registers itself into the application container and symbolizes its attributes. This is used by the db mapper to persist and retreive domains to and from the database.

NOTE: we are coupling ourselves to active record right now. I have

plans to resolve this but right now its a lower priority. You
can get around this by implementing your own mapper, and db model.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Application::AppContainer

#app_container, #feature_name, included, #qualify_container_key

Class Method Details

.container_class_typeString

Contributes to the construction of a fully qualified container key

Examples:

global model:  global.db.user
feature model: features.membership.db.user

Returns:

  • (String)


23
24
25
# File 'lib/appfuel/storage/db/active_record_model.rb', line 23

def self.container_class_type
  'db'
end

.inherited(klass) ⇒ Object

Registers the class inside the application container. The class being registered as the mixin required for registration.

Returns:

  • results from super



32
33
34
35
# File 'lib/appfuel/storage/db/active_record_model.rb', line 32

def self.inherited(klass)
  stage_class_for_registration(klass)
  super
end

Instance Method Details

#domain_attrsHash

Symbolize active record attributes and remove attributes with nil values

Returns:

  • (Hash)


41
42
43
# File 'lib/appfuel/storage/db/active_record_model.rb', line 41

def domain_attrs
  attributes.symbolize_keys.select {|_k, v| !v.nil? }
end