Module: PgLtree::ScopedFor

Defined in:
lib/pg_ltree/scoped_for.rb

Overview

Note:

When model have composite uniq key (for example: state + path), you should use this module for narrowing the scope

Narrowing the Scope for ActiveRecord Model

Author:

  • a.ponomarenko

Defined Under Namespace

Modules: InstanceMethods

Instance Method Summary collapse

Instance Method Details

#ltree_scoped_for(columns = []) ⇒ Object

Define base instance scope for model by columns

Parameters:

  • columns (Array) (defaults to: [])

    List of scoped fields


10
11
12
13
14
15
16
# File 'lib/pg_ltree/scoped_for.rb', line 10

def ltree_scoped_for(columns = [])
  cattr_accessor :ltree_scoped_for

  self.ltree_scoped_for = Array.wrap(columns)

  include InstanceMethods
end