Module: Ancestry::MaterializedPath2::InstanceMethods

Defined in:
lib/ancestry/materialized_path2.rb

Instance Method Summary collapse

Instance Method Details

#child_ancestryObject

Please see notes for MaterializedPath#child_ancestry



92
93
94
95
96
# File 'lib/ancestry/materialized_path2.rb', line 92

def child_ancestry
  raise(Ancestry::AncestryException, I18n.t("ancestry.no_child_for_new_record")) if new_record?

  MaterializedPath2.child_ancestry_value(attribute_in_database(self.class.ancestry_column), id, self.class.ancestry_delimiter)
end

#child_ancestry_before_last_saveObject

Please see notes for MaterializedPath#child_ancestry_before_last_save



99
100
101
102
103
104
105
# File 'lib/ancestry/materialized_path2.rb', line 99

def child_ancestry_before_last_save
  if new_record? || (respond_to?(:previously_new_record?) && previously_new_record?)
    raise(Ancestry::AncestryException, I18n.t("ancestry.no_child_for_new_record"))
  end

  MaterializedPath2.child_ancestry_value(attribute_before_last_save(self.class.ancestry_column), id, self.class.ancestry_delimiter)
end