class GlobalRegistryModels::ResponseParser

Public Class Methods

new(global_registry_response) click to toggle source
# File lib/global_registry_models/response_parser.rb, line 4
def initialize(global_registry_response)
  @response_hash = global_registry_response
end

Public Instance Methods

meta() click to toggle source
# File lib/global_registry_models/response_parser.rb, line 8
def meta
  @response_hash['meta'] if @response_hash['meta']
end
objects() click to toggle source
# File lib/global_registry_models/response_parser.rb, line 12
def objects
  @objects ||= build_entities if @response_hash['entities']
  @objects ||= build_other_types unless @response_hash['entities']
  @objects
end

Private Instance Methods

build_entities() click to toggle source
# File lib/global_registry_models/response_parser.rb, line 20
def build_entities
  @response_hash['entities'].collect(&:flatten).collect do |object_type, object_attributes|
    entity_class('Entity', object_type).new(object_attributes)
  end
end
build_other_types() click to toggle source
# File lib/global_registry_models/response_parser.rb, line 26
def build_other_types
  objects_type, objects = @response_hash.first
  objects.collect do |object_attributes|
    entity_class(objects_type, objects_type).new(object_attributes)
  end
end
entity_class(module_type, object_type) click to toggle source
# File lib/global_registry_models/response_parser.rb, line 33
def entity_class(module_type, object_type)
  return "GlobalRegistryModels::#{ module_type.classify }::#{ object_type.classify }".constantize 
end