Module: Ancestry

Defined in:
lib/ancestry.rb,
lib/ancestry/version.rb,
lib/ancestry/exceptions.rb,
lib/ancestry/has_ancestry.rb,
lib/ancestry/class_methods.rb,
lib/ancestry/instance_methods.rb,
lib/ancestry/materialized_path.rb,
lib/ancestry/materialized_path2.rb,
lib/ancestry/materialized_path_pg.rb

Defined Under Namespace

Modules: ClassMethods, HasAncestry, InstanceMethods, MaterializedPath, MaterializedPath2, MaterializedPathPg Classes: AncestryException, AncestryIntegrityException

Constant Summary collapse

VERSION =
'4.3.3'
@@default_update_strategy =
:ruby
@@default_ancestry_format =
:materialized_path
@@default_primary_key_format =
'[0-9]+'

Class Method Summary collapse

Class Method Details

.default_ancestry_formatObject

The value changes the default way that ancestry is stored in the database

:materialized_path (default and legacy)

    Ancestry is of the form null (for no ancestors) and 1/2/ for children

:materialized_path2 (preferred)

    Ancestry is of the form '/' (for no ancestors) and '/1/2/' for children


52
53
54
# File 'lib/ancestry.rb', line 52

def self.default_ancestry_format
  @@default_ancestry_format
end

.default_ancestry_format=(value) ⇒ Object



56
57
58
# File 'lib/ancestry.rb', line 56

def self.default_ancestry_format=(value)
  @@default_ancestry_format = value
end

.default_primary_key_formatObject

The value represents the way the id looks for validation

'[0-9]+' (default) for integer ids
'[-A-Fa-f0-9]{36}'    for uuids (though you can find other regular expressions)


67
68
69
# File 'lib/ancestry.rb', line 67

def self.default_primary_key_format
  @@default_primary_key_format
end

.default_primary_key_format=(value) ⇒ Object



71
72
73
# File 'lib/ancestry.rb', line 71

def self.default_primary_key_format=(value)
  @@default_primary_key_format = value
end

.default_update_strategyObject

The value changes the default way that ancestry is updated for associated records

:ruby (default and legacy value)

    Child records will be loaded into memory and updated. callbacks will get called
    The callbacks of interest are those that cache values based upon the ancestry value

:sql (currently only valid in postgres)

    Child records are updated in sql and callbacks will not get called.
    Associated records in memory will have the wrong ancestry value


32
33
34
# File 'lib/ancestry.rb', line 32

def self.default_update_strategy
  @@default_update_strategy
end

.default_update_strategy=(value) ⇒ Object



36
37
38
# File 'lib/ancestry.rb', line 36

def self.default_update_strategy=(value)
  @@default_update_strategy = value
end