Sha256: 8a6ce5e6f90d5f92b7c62d9ffe31c79e5dd4affbb625bb2d989dac768a202fc6

Contents?: true

Size: 557 Bytes

Versions: 11

Compression:

Stored size: 557 Bytes

Contents

require_relative 'field'
require_relative 'association'
require_relative 'types'

module Spectifly
  module Json
    class Builder < Spectifly::Base::Builder
      def build
        field_hashes = {}
        associations.each do |association|
          field_hashes[association.relationship] ||= {}
          field_hashes[association.relationship].merge! association.to_h
        end
        fields.each do |field|
          field_hashes.merge! field.to_h
        end
        { Spectifly::Support.tokenize(root) => field_hashes }
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spectifly-0.0.11 lib/spectifly/json/builder.rb
spectifly-0.0.10 lib/spectifly/json/builder.rb
spectifly-0.0.9 lib/spectifly/json/builder.rb
spectifly-0.0.8 lib/spectifly/json/builder.rb
spectifly-0.0.7 lib/spectifly/json/builder.rb
spectifly-0.0.6 lib/spectifly/json/builder.rb
spectifly-0.0.5 lib/spectifly/json/builder.rb
spectifly-0.0.4 lib/spectifly/json/builder.rb
spectifly-0.0.3 lib/spectifly/json/builder.rb
spectifly-0.0.2 lib/spectifly/json/builder.rb
spectifly-0.0.1 lib/spectifly/json/builder.rb