Class: Juvet::Mapper::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/juvet/mapper/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Collection

Returns a new instance of Collection.



8
9
10
11
# File 'lib/juvet/mapper/collection.rb', line 8

def initialize(name, &block)
  @name = name
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/juvet/mapper/collection.rb', line 6

def name
  @name
end

Instance Method Details

#entity(klass = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/juvet/mapper/collection.rb', line 13

def entity(klass=nil)
  if klass
    @entity = klass
  else
    @entity
  end
end

#repository(klass = nil, options = nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/juvet/mapper/collection.rb', line 21

def repository(klass=nil, options=nil)
  if klass
    @repository = MappedRepository.new klass, options
  else
    @repository
  end
end