Sha256: cbd11659d7dcc57a7fdc821830031e25678a6839a0efbd456a0a6c6789dc2e64

Contents?: true

Size: 436 Bytes

Versions: 1

Compression:

Stored size: 436 Bytes

Contents

module Transcriber
  class Resource
    module Response
      module Embeddable
        def to_resource(parent)
          return {} unless visible?(parent)

          resource = nil

          if embedded = parent.__send__(name)
            resource = one? ? embedded.resource : embedded.map(&:resource)
          elsif many?
            resource = []
          end

          {name => resource}
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transcriber-0.0.5 lib/transcriber/resource/response/embeddable.rb