Sha256: 563d7b250249a78ecbdb39edfa35864787f046e9f2303197ae4af931867ca95f

Contents?: true

Size: 665 Bytes

Versions: 9

Compression:

Stored size: 665 Bytes

Contents

module JsonApiClient
  module Linking
    class TopLevelLinks

      attr_reader :links, :record_class

      def initialize(record_class, links)
        @links = links
        @record_class = record_class
      end

      def respond_to_missing?(method, include_private = false)
        links.has_key?(method.to_s) || super
      end

      def method_missing(method, *args)
        if respond_to_missing?(method)
          fetch_link(method)
        else
          super
        end
      end

      def fetch_link(link_name)
        link_definition = links.fetch(link_name.to_s)
        record_class.requestor.linked(link_definition)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
json_api_client-1.0.2 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.1 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta7 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta6 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta5 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta4 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta3 lib/json_api_client/linking/top_level_links.rb
json_api_client-1.0.0.beta2 lib/json_api_client/linking/top_level_links.rb