Sha256: 2f2a5484dd285a9d642ae45e94f5b1af65379b5a699a7e4b04616073ad516e32

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

module GrapeEntityMatchers
  module Exposures
    private

    def exposures
      @exposures ||= extract_exposures(@subject.root_exposures)
    end

    def extract_exposures(exposures, hash = {}, prefix = nil)
      exposures.each_with_object(hash) do |exposure, hash|
        key = "#{prefix}#{exposure.attribute}"
        if exposure.is_a?(Grape::Entity::Exposure::NestingExposure)
          hash[key.to_sym] = Hash.new
          extract_exposures(exposure.nested_exposures.to_a, hash, "#{key}__")
        else
          hash[key.to_sym] = exposure
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-entity-matchers-1.3.0 lib/grape_entity_matchers/exposures.rb