Class: Dataset::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/dataset/resolver.rb

Overview

A dataset may be referenced as a class or as a name. A Dataset::Resolver will take an identifier, whether a class or a name, and return the class.

Direct Known Subclasses

DirectoryResolver

Instance Method Summary collapse

Instance Method Details

#identifiersObject


13
14
15
# File 'lib/dataset/resolver.rb', line 13

def identifiers
  @identifiers ||= {}
end

#resolve(identifier) ⇒ Object

Attempt to convert a name to a constant. With the identifier :people, it will search for 'PeopleDataset', then 'People'.


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dataset/resolver.rb', line 20

def resolve(identifier)
  return identifier if identifier.is_a?(Class)
  if constant = identifiers[identifier]
    return constant
  end

  constant = resolve_class(identifier)
  unless constant
    constant = resolve_identifier(identifier)
  end
  identifiers[identifier] = constant
end