Module: Guacamole::EdgeCollection

Extended by:
ActiveSupport::Concern
Includes:
Collection
Defined in:
lib/guacamole/edge_collection.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.create_edge_collection(collection_name) ⇒ Object



25
26
27
28
29
# File 'lib/guacamole/edge_collection.rb', line 25

def create_edge_collection(collection_name)
  new_collection_class = Class.new
  Object.const_set(collection_name, new_collection_class)
  new_collection_class.send(:include, Guacamole::EdgeCollection)
end

.for(edge_class) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/guacamole/edge_collection.rb', line 17

def for(edge_class)
  collection_name = [edge_class.name.pluralize, 'Collection'].join

  collection_name.constantize
rescue NameError
  create_edge_collection(collection_name)
end