Class: Juvet::Mapper
- Inherits:
-
Object
- Object
- Juvet::Mapper
- Defined in:
- lib/juvet/mapper.rb,
lib/juvet/mapper/collection.rb
Defined Under Namespace
Classes: Collection
Instance Attribute Summary collapse
-
#collections ⇒ Object
readonly
Returns the value of attribute collections.
Instance Method Summary collapse
- #collection(name, &block) ⇒ Object
- #collection_for_repository(klass) ⇒ Object
-
#initialize(&block) ⇒ Mapper
constructor
A new instance of Mapper.
Constructor Details
#initialize(&block) ⇒ Mapper
Returns a new instance of Mapper.
7 8 9 10 11 |
# File 'lib/juvet/mapper.rb', line 7 def initialize(&block) @collections = {} instance_eval(&block) if block_given? end |
Instance Attribute Details
#collections ⇒ Object (readonly)
Returns the value of attribute collections.
5 6 7 |
# File 'lib/juvet/mapper.rb', line 5 def collections @collections end |
Instance Method Details
#collection(name, &block) ⇒ Object
13 14 15 |
# File 'lib/juvet/mapper.rb', line 13 def collection(name, &block) collections[name] = Juvet::Mapper::Collection.new name, &block end |
#collection_for_repository(klass) ⇒ Object
17 18 19 |
# File 'lib/juvet/mapper.rb', line 17 def collection_for_repository(klass) collections.values.find { |collection| collection.repository == klass } end |