Sha256: a4ad7b4eff19f19919daf06e1debb449bace2e28ac58b6964cbd685c9bc480d4

Contents?: true

Size: 746 Bytes

Versions: 14

Compression:

Stored size: 746 Bytes

Contents

require "shamu/json_api/base_builder"

module Shamu
  module JsonApi

    # Build a relationship from one resource to another.
    class RelationshipBuilder < BaseBuilder


      # (see Context#include_resource)
      def include_resource( resource, presenter = nil, &block )
        context.include_resource resource, presenter, &block
      end

      include BuilderMethods::Identifier

      # Write a resource linkage info.
      #
      # @param [String] type of the resource.
      # @param [Object] id of the resource.
      # @return [void]
      def identifier( type, id = nil )
        output[:data] ||= {}
        output[:data][:type] = @type = type.to_s
        output[:data][:id]   = id.to_s
        self
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shamu-0.0.24 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.21 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.20 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.19 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.18 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.17 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.15 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.14 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.13 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.11 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.9 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.8 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.7 lib/shamu/json_api/relationship_builder.rb
shamu-0.0.5 lib/shamu/json_api/relationship_builder.rb