Module: RDFMapper::Adapters

Defined in:
lib/lib/adapters/base.rb,
lib/lib/adapters/rest.rb,
lib/lib/adapters/rails.rb,
lib/lib/adapters/sparql.rb

Defined Under Namespace

Classes: Base, REST, Rails, SPARQL

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Returns adapter’s class based on specified ‘name` (:rails, :sparql, :rest)

Returns:

  • (Object)


26
27
28
29
30
31
32
33
# File 'lib/lib/adapters/base.rb', line 26

def self.[](name)
  case name
    when :rails   then Rails
    when :sparql  then SPARQL
    when :rest    then REST
    else raise NameError, 'Adapter `%s` not recognized' % value.inspect
  end
end

.register(name, cls, options = {}) ⇒ Object

Instantiates and returns an instance of an adapter.

Parameters:

  • name (Symbol)

    (:rails, :sparql, :rest)

  • cls (Object)

    subclass of RDFMapper::Model

  • options (Hash) (defaults to: {})

    options to pass on to the adapter constructor

Returns:

  • (Object)

    instance of an adapter



17
18
19
# File 'lib/lib/adapters/base.rb', line 17

def self.register(name, cls, options = {})
  self[name].new(cls, options)
end