Class: Granite::Form::Model::Associations::PersistenceAdapters::Base
- Inherits:
-
Object
- Object
- Granite::Form::Model::Associations::PersistenceAdapters::Base
- Defined in:
- lib/granite/form/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.
- #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.
9 10 11 12 13 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 9 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.
7 8 9 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 7 def data_source @data_source end |
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
7 8 9 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 7 def primary_key @primary_key end |
#scope_proc ⇒ Object (readonly)
Returns the value of attribute scope_proc.
7 8 9 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 7 def scope_proc @scope_proc end |
Instance Method Details
#build(_attributes) ⇒ Object
15 16 17 18 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 15 def build(_attributes) raise NotImplementedError, 'Should be implemented in inhereted adapter. Build new instance of data object by attributes' end |
#data_type ⇒ Object
37 38 39 40 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 37 def data_type raise NotImplementedError, 'Should be implemented in inhereted adapter. Type of data object for type_check' end |
#find_all(owner, identificators) ⇒ Object
28 29 30 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 28 def find_all(owner, identificators) scope(owner, identificators).to_a end |
#find_one(owner, identificator) ⇒ Object
24 25 26 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 24 def find_one(owner, identificator) scope(owner, identificator).first end |
#identify(_object) ⇒ Object
32 33 34 35 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 32 def identify(_object) raise NotImplementedError, 'Should be implemented in inhereted adapter. Field to be used as primary_key for object' end |
#primary_key_type ⇒ Object
42 43 44 |
# File 'lib/granite/form/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 49 |
# File 'lib/granite/form/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
20 21 22 |
# File 'lib/granite/form/model/associations/persistence_adapters/base.rb', line 20 def scope(_owner, _source) raise NotImplementedError, 'Should be implemented in inhereted adapter. Better to be Enumerable' end |