Class: ActiveData::Model::Associations::PersistenceAdapters::Base
- Inherits:
-
Object
- Object
- ActiveData::Model::Associations::PersistenceAdapters::Base
- Defined in:
- lib/active_data/model/associations/persistence_adapters/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_source ⇒ Object
readonly
Returns the value of attribute data_source.
-
#primary_key ⇒ Object
readonly
Returns the value of attribute primary_key.
-
#scope_proc ⇒ Object
readonly
Returns the value of attribute scope_proc.
Instance Method Summary collapse
- #build(_attributes) ⇒ Object
- #data_type ⇒ Object
- #find_all(owner, identificators) ⇒ Object
- #find_one(owner, identificator) ⇒ Object
- #identify(_object) ⇒ Object
-
#initialize(data_source, primary_key, scope_proc = nil) ⇒ Base
constructor
A new instance of Base.
- #persist(_object) ⇒ Object
- #primary_key_type ⇒ Object
- #referenced_proxy ⇒ Object
- #scope(_owner, _source) ⇒ Object
Constructor Details
#initialize(data_source, primary_key, scope_proc = nil) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 8 def initialize(data_source, primary_key, scope_proc = nil) @data_source = data_source @primary_key = primary_key @scope_proc = scope_proc end |
Instance Attribute Details
#data_source ⇒ Object (readonly)
Returns the value of attribute data_source.
6 7 8 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 6 def data_source @data_source end |
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
6 7 8 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 6 def primary_key @primary_key end |
#scope_proc ⇒ Object (readonly)
Returns the value of attribute scope_proc.
6 7 8 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 6 def scope_proc @scope_proc end |
Instance Method Details
#build(_attributes) ⇒ Object
14 15 16 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 14 def build(_attributes) raise NotImplementedError, 'Should be implemented in inhereted adapter. Build new instance of data object by attributes' end |
#data_type ⇒ Object
38 39 40 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 38 def data_type raise NotImplementedError, 'Should be implemented in inhereted adapter. Type of data object for type_check' end |
#find_all(owner, identificators) ⇒ Object
30 31 32 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 30 def find_all(owner, identificators) scope(owner, identificators).to_a end |
#find_one(owner, identificator) ⇒ Object
26 27 28 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 26 def find_one(owner, identificator) scope(owner, identificator).first end |
#identify(_object) ⇒ Object
34 35 36 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 34 def identify(_object) raise NotImplementedError, 'Should be implemented in inhereted adapter. Field to be used as primary_key for object' end |
#persist(_object) ⇒ Object
18 19 20 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 18 def persist(_object, *) raise NotImplementedError, 'Should be implemented in inhereted adapter. Build new instance of data object by attributes' end |
#primary_key_type ⇒ Object
42 43 44 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 42 def primary_key_type raise NotImplementedError, 'Should be implemented in inhereted adapter. Ruby data type' end |
#referenced_proxy ⇒ Object
46 47 48 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 46 def referenced_proxy raise NotImplementedError, 'Should be implemented in inhereted adapter. Object to manage proxying of methods to scope.' end |
#scope(_owner, _source) ⇒ Object
22 23 24 |
# File 'lib/active_data/model/associations/persistence_adapters/base.rb', line 22 def scope(_owner, _source) raise NotImplementedError, 'Should be implemented in inhereted adapter. Better to be Enumerable' end |