Module: TestingRecord::DSL::Builder::Settings
- Includes:
- Validation::Input
- Included in:
- Model
- Defined in:
- lib/testing_record/dsl/builder/settings.rb
Overview
- TestingRecord::DSL::Builder::Settings
-
Ways in which we can configure our individual models
Instance Method Summary collapse
- #__primary_key ⇒ Object
-
#caching(option) ⇒ Symbol
Create a cache of the entities, named according to the classname.
-
#primary_key(option) ⇒ Symbol
Sets the primary key value of all entities - used for deduplication TODO: Use this for deduplication proper.
Methods included from Validation::Input
Instance Method Details
#__primary_key ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/testing_record/dsl/builder/settings.rb', line 13 def __primary_key if instance_variable_defined?(:@__primary_key) @__primary_key elsif superclass.respond_to?(:__primary_key) superclass.__primary_key else TestingRecord.default_primary_key end end |
#caching(option) ⇒ Symbol
Create a cache of the entities, named according to the classname
26 27 28 29 30 31 32 |
# File 'lib/testing_record/dsl/builder/settings.rb', line 26 def caching(option) raise Error::InvalidConfigurationError, 'Invalid caching option, must be :enabled or :disabled' unless caching_valid?(option) return unless option == :enabled instance_variable_set(:@all, []) define_singleton_method(:all) { instance_variable_get(:@all) } end |
#primary_key(option) ⇒ Symbol
Sets the primary key value of all entities - used for deduplication TODO: Use this for deduplication proper
38 39 40 41 42 |
# File 'lib/testing_record/dsl/builder/settings.rb', line 38 def primary_key(option) raise Error::InvalidConfigurationError, 'Invalid primary key value, must be a Symbol' unless option.is_a?(Symbol) instance_variable_set(:@__primary_key, option) end |