Class: Terrestrial::Configurations::ConventionalConfiguration
- Inherits:
-
Object
- Object
- Terrestrial::Configurations::ConventionalConfiguration
- Includes:
- Enumerable, Fetchable
- Defined in:
- lib/terrestrial/configurations/conventional_configuration.rb
Defined Under Namespace
Classes: ArbitraryDatabaseDefaultValueObserver, ArbitraryDatabaseOwnedValueObserver, ClassFactory, DatabaseIDObserver, HashCoercionSerializer, LazyClassLookupFactory, SetterMethodCaller, TableNameNotSpecifiedError, TimestampObserver
Instance Attribute Summary collapse
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#datastore ⇒ Object
readonly
Returns the value of attribute datastore.
-
#dirty_map ⇒ Object
readonly
Returns the value of attribute dirty_map.
-
#identity_map ⇒ Object
readonly
Returns the value of attribute identity_map.
-
#inflector ⇒ Object
readonly
Returns the value of attribute inflector.
-
#mappings ⇒ Object
readonly
Returns the value of attribute mappings.
-
#overrides ⇒ Object
readonly
Returns the value of attribute overrides.
Instance Method Summary collapse
- #add_association(mapping_name, type, options) ⇒ Object
- #add_override(mapping_name, attrs) ⇒ Object
- #add_subset(mapping_name, subset_name, block) ⇒ Object
-
#initialize(datastore:, clock:, dirty_map:, identity_map:, inflector: Inflector.new) ⇒ ConventionalConfiguration
constructor
A new instance of ConventionalConfiguration.
- #setup_mapping(mapping_name, &block) ⇒ Object
Constructor Details
#initialize(datastore:, clock:, dirty_map:, identity_map:, inflector: Inflector.new) ⇒ ConventionalConfiguration
Returns a new instance of ConventionalConfiguration.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 30 def initialize(datastore:, clock:, dirty_map:, identity_map:, inflector: Inflector.new) @datastore = datastore @inflector = inflector @dirty_map = dirty_map @identity_map = identity_map @clock = clock @overrides = {} @subset_queries = {} @associations_by_mapping = {} end |
Instance Attribute Details
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def clock @clock end |
#datastore ⇒ Object (readonly)
Returns the value of attribute datastore.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def datastore @datastore end |
#dirty_map ⇒ Object (readonly)
Returns the value of attribute dirty_map.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def dirty_map @dirty_map end |
#identity_map ⇒ Object (readonly)
Returns the value of attribute identity_map.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def identity_map @identity_map end |
#inflector ⇒ Object (readonly)
Returns the value of attribute inflector.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def inflector @inflector end |
#mappings ⇒ Object (readonly)
Returns the value of attribute mappings.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def mappings @mappings end |
#overrides ⇒ Object (readonly)
Returns the value of attribute overrides.
42 43 44 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 42 def overrides @overrides end |
Instance Method Details
#add_association(mapping_name, type, options) ⇒ Object
74 75 76 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 74 def add_association(mapping_name, type, ) @associations_by_mapping.fetch(mapping_name).push([type, ]) end |
#add_override(mapping_name, attrs) ⇒ Object
59 60 61 62 63 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 59 def add_override(mapping_name, attrs) overrides = @overrides.fetch(mapping_name, {}).merge(attrs) @overrides.store(mapping_name, overrides) end |
#add_subset(mapping_name, subset_name, block) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 65 def add_subset(mapping_name, subset_name, block) @subset_queries.store( mapping_name, @subset_queries.fetch(mapping_name, {}).merge( subset_name => block, ) ) end |
#setup_mapping(mapping_name, &block) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/terrestrial/configurations/conventional_configuration.rb', line 44 def setup_mapping(mapping_name, &block) @associations_by_mapping[mapping_name] ||= [] @overrides[mapping_name] ||= {} block && block.call( MappingConfigOptionsProxy.new(self, mapping_name) ) self end |