Sha256: ca3f68de43be265509c7ee29599fe914673b18c45b1a46df65d571d0ccaa1fe4

Contents?: true

Size: 939 Bytes

Versions: 8

Compression:

Stored size: 939 Bytes

Contents

require "jsonapi/consumer"
require "jsonapi/consumer/decorators"
require 'yaml'

module Commercelayer

  JSONAPI::Consumer::Paginating::Paginator.page_param = "page[number]"

  class Resource < JSONAPI::Consumer::Resource
    # self.connection_options = {} # Faraday connection options
    # self.json_key_format = :dasherized_key # (default: underscored_key)
    # self.route_format = :dasherized_route # (default: underscored_route)
    # self.site = 'http://uashmama.commercelayer.test/api/'
  end

  resources = YAML::load_file(File.join(__dir__, '../../config/resources.yml'))["resources"].deep_symbolize_keys

  resources.each do |resource_key, resource_values|
    resource_class = Class.new(Resource) do
      resource_values[:relationships].each do |name, options|
        send options[:type], name, class_name: options[:class_name]
      end
    end
    Commercelayer.const_set(resource_values[:name], resource_class)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
commercelayer-0.8.2 lib/commercelayer/resource.rb
commercelayer-0.8.1 lib/commercelayer/resource.rb
commercelayer-0.8.0 lib/commercelayer/resource.rb
commercelayer-0.7.0 lib/commercelayer/resource.rb
commercelayer-0.6.0 lib/commercelayer/resource.rb
commercelayer-0.5.0 lib/commercelayer/resource.rb
commercelayer-0.4.0 lib/commercelayer/resource.rb
commercelayer-0.3.0 lib/commercelayer/resource.rb