Class: Lycra::Document::Registry

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/lycra/document/registry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(documents = []) ⇒ Registry

Returns a new instance of Registry.



25
26
27
# File 'lib/lycra/document/registry.rb', line 25

def initialize(documents=[])
  @documents = documents
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, **opts, &block) ⇒ Object



33
34
35
# File 'lib/lycra/document/registry.rb', line 33

def method_missing(meth, *args, **opts, &block)
  documents.map { |doc| doc.send(meth, *args, **opts, &block) }
end

Instance Attribute Details

#documentsObject (readonly)

Returns the value of attribute documents.



22
23
24
# File 'lib/lycra/document/registry.rb', line 22

def documents
  @documents
end

Class Method Details

.__instanceObject



9
10
11
# File 'lib/lycra/document/registry.rb', line 9

def __instance
  @instance ||= new
end

.abstractObject



17
18
19
# File 'lib/lycra/document/registry.rb', line 17

def abstract
  new(documents.select(&:abstract?))
end

.allObject



13
14
15
# File 'lib/lycra/document/registry.rb', line 13

def all
  new(documents.reject(&:abstract?))
end

Instance Method Details

#add(klass) ⇒ Object



29
30
31
# File 'lib/lycra/document/registry.rb', line 29

def add(klass)
  @documents << klass
end