Module: Vedeu::Repositories::Model::SingletonMethods Private
- Defined in:
- lib/vedeu/repositories/model.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provide additional behaviour as singleton methods to the including class or module.
Instance Attribute Summary collapse
- #repository ⇒ Vedeu::Repositories::Repository readonly private
Instance Method Summary collapse
-
#build(attributes = {}, &block) ⇒ Object
private
Build models using a simple DSL when a block is given, otherwise returns a new instance of the class including this module.
-
#repo(klass) ⇒ void
private
Allow models to specify their repository using a class method.
-
#store(attributes = {}, &block) ⇒ Object
private
Create and store a model with the given attributes.
Instance Attribute Details
#repository ⇒ Vedeu::Repositories::Repository (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/vedeu/repositories/model.rb', line 23 def repository @repository end |
Instance Method Details
#build(attributes = {}, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build models using a simple DSL when a block is given, otherwise returns a new instance of the class including this module.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vedeu/repositories/model.rb', line 33 def build(attributes = {}, &block) model = new(attributes) Vedeu.log(type: :debug, message: "DSL building: '#{model.class.name}' for " \ "'#{model.name}'") model.deputy.instance_eval(&block) if block_given? model end |
#repo(klass) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Allow models to specify their repository using a class method.
50 51 52 |
# File 'lib/vedeu/repositories/model.rb', line 50 def repo(klass) @repository = klass end |
#store(attributes = {}, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create and store a model with the given attributes.
60 61 62 |
# File 'lib/vedeu/repositories/model.rb', line 60 def store(attributes = {}, &block) new(attributes).store(&block) end |