Module: PgLtree::Ltree

Defined in:
lib/pg_ltree/ltree.rb

Overview

Implementatios Postgres ltree for ActiveRecord

See Also:

Author:

  • a.ponomarenko

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Method Summary collapse

Instance Method Details

#ltree(column = :path, options: { cascade: true }) ⇒ Object

Initialzie ltree for active model

Parameters:

  • column (String) (defaults to: :path)

    ltree column name


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pg_ltree/ltree.rb', line 12

def ltree(column = :path, options: { cascade: true })
  cattr_accessor :ltree_path_column

  self.ltree_path_column = column

  if options[:cascade]
    after_update :cascade_update
    after_destroy :cascade_destroy
  end

  extend ClassMethods
  include InstanceMethods
end