Class: RPCMapper::Adapters::AbstractAdapter

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/rpc_mapper/adapters/abstract_adapter.rb

Direct Known Subclasses

BERTRPCAdapter, RestfulHTTPAdapter

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

included

Constructor Details

#initialize(type, config) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter.



11
12
13
14
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 11

def initialize(type, config)
  @type = type.to_sym
  @configuration_contexts = config.is_a?(Array) ? config : [config]
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 7

def config
  @config
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 8

def type
  @type
end

Class Method Details

.create(type, config) ⇒ Object



16
17
18
19
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 16

def self.create(type, config)
  klass = type ? @@registered_adapters[type.to_sym] : self
  klass.new(type, config)
end

.register_as(name) ⇒ Object



41
42
43
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 41

def self.register_as(name)
  @@registered_adapters[name.to_sym] = self
end

Instance Method Details

#delete(object) ⇒ Object

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 37

def delete(object)
  raise NotImplementedError, "You must not use the abstract adapter.  Implement an adapter that extends the RPCMapper::Adapters::Abstract::Base class and overrides this method."
end

#extend_adapter(config) ⇒ Object



21
22
23
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 21

def extend_adapter(config)
  self.class.create(self.type, @configuration_contexts + [*config])
end

#read(options) ⇒ Object

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 29

def read(options)
  raise NotImplementedError, "You must not use the abstract adapter.  Implement an adapter that extends the RPCMapper::Adapters::Abstract::Base class and overrides this method."
end

#write(object) ⇒ Object

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/rpc_mapper/adapters/abstract_adapter.rb', line 33

def write(object)
  raise NotImplementedError, "You must not use the abstract adapter.  Implement an adapter that extends the RPCMapper::Adapters::Abstract::Base class and overrides this method."
end