Sha256: 27fa1da62ff12aaf4ea09a3fd3d8963d9cca9b07b748d15ecbbb8ddc9cacd6a9

Contents?: true

Size: 673 Bytes

Versions: 2

Compression:

Stored size: 673 Bytes

Contents

module RockRMS
  module Responses
    class GroupLocation
      MAP = {
        id: 'Id',
        group_id: 'GroupId',
        location_id: 'LocationId',
        guid: 'Guid'
      }.freeze

      def self.format(data)
        if data.is_a?(Array)
          data.map { |object| format_single(object) }
        else
          format_single(data)
        end
      end

      private

      def self.format_single(data)
        result = MAP.each.with_object({}) do |(l,r), object|
          object[l] = data[r]
        end

        if location = data['Location']
          result[:location] = Location.format(location)
        end

        result
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rock_rms-1.2.0 lib/rock_rms/responses/group_location.rb
rock_rms-1.1.0 lib/rock_rms/responses/group_location.rb