Sha256: c5db9d80970ab47ead8f570e6b2891f1512625d6230ea8d461bf772344f119b5

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

module JsonApiClient
  module Linking
    class Links
      include Helpers::DynamicAttributes

      def initialize(links)
        self.attributes = links
      end

      def present?
        attributes.present?
      end

      protected

      def set_attribute(name, value)
        attributes[name] = case value
        when JsonApiClient::Resource
          {linkage: value.as_link}
        when Array
          {linkage: value.map(&:as_link)}
        else
          value
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
json_api_client-1.0.0.beta lib/json_api_client/linking/links.rb