Class: Ant::Server::Nanoservice::Factory
- Inherits:
-
Object
- Object
- Ant::Server::Nanoservice::Factory
- Includes:
- DRY::ResourceInjector
- Defined in:
- lib/ant/server/nanoservice/factory.rb
Instance Method Summary collapse
- #create(data, source = resource(:default)) ⇒ Object
- #get(id, source = resource(:default)) ⇒ Object
-
#initialize(model) ⇒ Factory
constructor
A new instance of Factory.
Methods included from DRY::ResourceInjector
#register, #resource, #resources
Constructor Details
#initialize(model) ⇒ Factory
Returns a new instance of Factory.
7 8 9 |
# File 'lib/ant/server/nanoservice/factory.rb', line 7 def initialize(model) @model = model end |
Instance Method Details
#create(data, source = resource(:default)) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/ant/server/nanoservice/factory.rb', line 11 def create(data, source = resource(:default)) repository = resource(source) model = @model.new(data) model.repository = repository model.create model end |
#get(id, source = resource(:default)) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/ant/server/nanoservice/factory.rb', line 19 def get(id, source = resource(:default)) repository = resource(source) data = repository.get(id) model = @model.new(data) model.repository = repository model end |