Module: ActiverecordCursorPagination

Defined in:
lib/activerecord_cursor_pagination.rb,
lib/activerecord_cursor_pagination/cursor.rb,
lib/activerecord_cursor_pagination/version.rb,
lib/activerecord_cursor_pagination/extension.rb,
lib/activerecord_cursor_pagination/order_base.rb,
lib/activerecord_cursor_pagination/serializer.rb,
lib/activerecord_cursor_pagination/sql_signer.rb,
lib/activerecord_cursor_pagination/cursor_scope.rb,
lib/activerecord_cursor_pagination/empty_cursor.rb,
lib/activerecord_cursor_pagination/configuration.rb,
lib/activerecord_cursor_pagination/ascending_order.rb,
lib/activerecord_cursor_pagination/class_formatter.rb,
lib/activerecord_cursor_pagination/model_extension.rb,
lib/activerecord_cursor_pagination/descending_order.rb,
lib/activerecord_cursor_pagination/secret_key_finder.rb,
lib/activerecord_cursor_pagination/secure_cursor_serializer.rb

Defined Under Namespace

Modules: Extension, ModelExtension Classes: AscendingOrder, ClassFormatter, Configuration, Cursor, CursorError, CursorScope, DescendingOrder, EmptyCursor, Error, InvalidCursorError, NoSecretKeyError, NotSingleRecordError, OrderBase, SecretKeyFinder, SecureCursorSerializer, Serializer, SqlSigner

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject (readonly)

Returns the value of attribute configuration.



39
40
41
# File 'lib/activerecord_cursor_pagination.rb', line 39

def configuration
  @configuration
end

Class Method Details

.connectionObject



73
74
75
# File 'lib/activerecord_cursor_pagination.rb', line 73

def connection
  ActiveRecord::Base.connection
end

.quote_column(name) ⇒ Object



57
58
59
# File 'lib/activerecord_cursor_pagination.rb', line 57

def quote_column(name)
  valid_name?(name) ? connection.quote_column_name(name) : name
end

.quote_table(table) ⇒ Object



53
54
55
# File 'lib/activerecord_cursor_pagination.rb', line 53

def quote_table(table)
  table_exists?(table) ? connection.quote_table_name(table) : table
end

.quote_table_column(table, name) ⇒ Object



49
50
51
# File 'lib/activerecord_cursor_pagination.rb', line 49

def quote_table_column(table, name)
  table.nil? || table.empty? ? quote_column(name) : "#{quote_table table}.#{quote_column name}"
end

.setup(&block) ⇒ Object



45
46
47
# File 'lib/activerecord_cursor_pagination.rb', line 45

def setup(&block)
  block.call configuration if block
end

.strip_quotes(name) ⇒ Object



61
62
63
# File 'lib/activerecord_cursor_pagination.rb', line 61

def strip_quotes(name)
  name&.gsub '"', ''
end

.table_exists?(table) ⇒ Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/activerecord_cursor_pagination.rb', line 69

def table_exists?(table)
  valid_name?(table) && connection.table_exists?(table)
end

.valid_name?(name) ⇒ Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/activerecord_cursor_pagination.rb', line 65

def valid_name?(name)
  /\A[\w_]+\z/.match? name
end