Class: PgEventstore::Web::Paginator::BaseCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/pg_eventstore/web/paginator/base_collection.rb,
sig/pg_eventstore/web/paginator/base_collection.rbs

Constant Summary collapse

MIN_QUERY_SIZE_FOR_ADVANCE_SEARCH =

This is the minimum amount of symbols requeried to perform search using trigrams gin index

Returns:

  • (Integer)
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_name, starting_id:, per_page:, order:, options: {}) ⇒ BaseCollection

Returns a new instance of BaseCollection.

Parameters:

  • config_name (Symbol)
  • starting_id (String, Integer, nil)
  • per_page (Integer)
  • order (Symbol)

    :asc or :desc

  • options (Hash) (defaults to: {})

    additional options to filter the collection



31
32
33
34
35
36
37
38
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 31

def initialize(config_name, starting_id:, per_page:, order:, options: {})
  @config_name = config_name
  @starting_id = starting_id
  @per_page = per_page
  @order = order
  @options =
    options.is_a?(Sinatra::IndifferentHash) ? Utils.deep_transform_keys(Hash[options], &:to_sym) : options
end

Instance Attribute Details

#config_nameSymbol

Returns the value of attribute config_name.

Returns:

  • (Symbol)


12
13
14
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 12

def config_name
  @config_name
end

#options::Hash[untyped, untyped]

Returns the value of attribute options.

Returns:

  • (::Hash[untyped, untyped])


24
25
26
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 24

def options
  @options
end

#orderSymbol

Returns the value of attribute order.

Returns:

  • (Symbol)


21
22
23
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 21

def order
  @order
end

#per_pageInteger

Returns the value of attribute per_page.

Returns:

  • (Integer)


18
19
20
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 18

def per_page
  @per_page
end

#starting_idString, ...

Returns the value of attribute starting_id.

Returns:

  • (String, Integer, nil)


15
16
17
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 15

def starting_id
  @starting_id
end

Instance Method Details

#collectionArray

Returns:

  • (Array)

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 41

def collection
  raise NotImplementedError
end

#connectionPgEventstore::Connection



68
69
70
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 68

def connection
  PgEventstore.connection(config_name)
end

#countInteger

Returns:

  • (Integer)


46
47
48
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 46

def count
  collection.size
end

#next_page_starting_idString, ...

Returns:

  • (String, Integer, nil)

Raises:

  • (NotImplementedError)


51
52
53
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 51

def next_page_starting_id
  raise NotImplementedError
end

#prev_page_starting_idString, ...

Returns:

  • (String, Integer, nil)

Raises:

  • (NotImplementedError)


56
57
58
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 56

def prev_page_starting_id
  raise NotImplementedError
end

#total_countInteger

Returns:

  • (Integer)

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/pg_eventstore/web/paginator/base_collection.rb', line 61

def total_count
  raise NotImplementedError
end