Sha256: 3e6bb7d52c550908977c81eaf0ba28670dca0dec03ed64e71641abb149091005

Contents?: true

Size: 688 Bytes

Versions: 4

Compression:

Stored size: 688 Bytes

Contents

module Shamu
  module JsonApi
    module BuilderMethods
      module Identifier
        # Write a resource linkage info.
        #
        # @param [String] type of the resource.
        # @param [Object] id of the resource.
        # @return [self]
        def identifier( type, id = nil )
          output[:type] = @type = type.to_s
          output[:id]   = id.to_s

          self
        end

        # (see BaseBuilder#compile)
        def compile
          require_identifier!
          super
        end

        private

          attr_reader :type

          def require_identifier!
            fail IncompleteResourceError unless type
          end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shamu-0.0.9 lib/shamu/json_api/builder_methods/identifier.rb
shamu-0.0.8 lib/shamu/json_api/builder_methods/identifier.rb
shamu-0.0.7 lib/shamu/json_api/builder_methods/identifier.rb
shamu-0.0.5 lib/shamu/json_api/builder_methods/identifier.rb