Class: SupportTable::Definition Private

Inherits:
Object
  • Object
show all
Defined in:
lib/support_table/definition.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class to define support table behavior on an ActiveRecord class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Definition

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Definition.



10
11
12
# File 'lib/support_table/definition.rb', line 10

def initialize(klass)
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/support_table/definition.rb', line 8

def klass
  @klass
end

Instance Method Details

#support_table(data_file:, key_attribute:, attribute_helpers:, cache_by:, cache:, ttl:) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Setup a class to be a support table.

Parameters:

  • data_file (String, Array<String>, nil)

    Path to data files to load the table from.

  • key_attribute (String, Symbol, nil)

    The name of the attribute in the data file that uniquely identifies each row in the data.

  • cache_by (String, Symbol, Array, nil)

    List of attributes that can be used to uniquely identify a row that can be used for caching records.

  • cache (ActiveSupport::Cache::Store, Symbol, Boolean, nil)

    The caching mechanism to use.

  • ttl (Numeric, ActiveSupport::Duration, nil)

    The time-to-live (in seconds) for cached records.



24
25
26
27
28
29
30
# File 'lib/support_table/definition.rb', line 24

def support_table(data_file:, key_attribute:, attribute_helpers:, cache_by:, cache:, ttl:)
  include_modules
  set_key_attribute(key_attribute)
  set_attribute_helpers(attribute_helpers)
  set_data_file(data_file)
  setup_caching(cache_by, cache, ttl)
end