Sha256: b6657950bcc1379ef79e260c36615fbd98560c55aaae8fc727212279a0889d5c

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

module Uatu
  module Endpoints
    module Nested

      Uatu::RESOURCES.each do |resource|
        # example: GET /v1/public/characters/{characterId}/comics => Uatu::Base.new.character_comics
        RESOURCES.each do |nested_resource|
          unless nested_resource == resource
            define_method "#{resource}_#{nested_resource.pluralize}" do |id, options={}|
              raise Uatu::Error::BadRequest.new('options must be in a Hash') unless options.is_a?(Hash)
              options.merge!("#{resource}_id".to_sym => id)
              resource = "#{resource}_#{nested_resource.pluralize}"
              connection = Uatu::Connection.new resource, options

              request_and_build connection
            end
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uatu-marvel-0.1.0 lib/uatu/endpoints/nested.rb