Class: Valkyrie::Persistence::Postgres::ResourceFactory
- Inherits:
-
Object
- Object
- Valkyrie::Persistence::Postgres::ResourceFactory
- Defined in:
- lib/valkyrie/persistence/postgres/resource_factory.rb
Overview
Provides access to generic methods for converting to/from Resource and ORM::Resource.
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
Instance Method Summary collapse
-
#from_resource(resource:) ⇒ Valkyrie::Persistence::Postgres::ORM::Resource
ActiveRecord resource for the Valkyrie resource.
-
#initialize(adapter:) ⇒ ResourceFactory
constructor
A new instance of ResourceFactory.
-
#orm_class ⇒ Class
Accessor for the ActiveRecord class which all Postgres resources are an instance of.
-
#to_resource(object:) ⇒ Valkyrie::Resource
Model representation of the AR record.
Constructor Details
#initialize(adapter:) ⇒ ResourceFactory
Returns a new instance of ResourceFactory.
12 13 14 |
# File 'lib/valkyrie/persistence/postgres/resource_factory.rb', line 12 def initialize(adapter:) @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/valkyrie/persistence/postgres/resource_factory.rb', line 8 def adapter @adapter end |
Instance Method Details
#from_resource(resource:) ⇒ Valkyrie::Persistence::Postgres::ORM::Resource
Returns ActiveRecord resource for the Valkyrie resource.
26 27 28 |
# File 'lib/valkyrie/persistence/postgres/resource_factory.rb', line 26 def from_resource(resource:) ::Valkyrie::Persistence::Postgres::ResourceConverter.new(resource, resource_factory: self).convert! end |
#orm_class ⇒ Class
Accessor for the ActiveRecord class which all Postgres resources are an instance of.
33 34 35 |
# File 'lib/valkyrie/persistence/postgres/resource_factory.rb', line 33 def orm_class ::Valkyrie::Persistence::Postgres::ORM::Resource end |
#to_resource(object:) ⇒ Valkyrie::Resource
Returns Model representation of the AR record.
19 20 21 |
# File 'lib/valkyrie/persistence/postgres/resource_factory.rb', line 19 def to_resource(object:) ::Valkyrie::Persistence::Postgres::ORMConverter.new(object, resource_factory: self).convert! end |