Module: BrainstemAdaptor

Defined in:
lib/brainstem-adaptor.rb,
lib/brainstem_adaptor/record.rb,
lib/brainstem_adaptor/response.rb,
lib/brainstem_adaptor/association.rb,
lib/brainstem_adaptor/specification.rb,
lib/brainstem_adaptor/invalid_response_error.rb

Defined Under Namespace

Classes: Association, InvalidResponseError, Record, Response, Specification

Constant Summary collapse

VERSION =
'0.0.3'

Class Method Summary collapse

Class Method Details

.default_specificationBrainstemAdaptor::Specification



27
28
29
# File 'lib/brainstem-adaptor.rb', line 27

def self.default_specification
  BrainstemAdaptor::Specification[:default]
end

.load_specification(path) ⇒ Object

Parameters:

  • path (String)

    Path to YML specification file



37
38
39
# File 'lib/brainstem-adaptor.rb', line 37

def self.load_specification(path)
  self.specification = YAML::load_file(path)
end

.parserObject



15
16
17
# File 'lib/brainstem-adaptor.rb', line 15

def self.parser
  @parser ||= JSON
end

.parser=(parser) ⇒ Object

Parameters:

  • parser

    Any JSON parser

Raises:

  • (ArgumentError)

    if parser does not respond to #parse



21
22
23
24
# File 'lib/brainstem-adaptor.rb', line 21

def self.parser=(parser)
  raise ArgumentError, 'Parser must respond to #parse message' unless parser.respond_to?(:parse)
  @parser = parser
end

.specification=(specification) ⇒ Object

Parameters:

  • specification (Hash)


32
33
34
# File 'lib/brainstem-adaptor.rb', line 32

def self.specification=(specification)
  BrainstemAdaptor::Specification[:default] = specification
end