Sha256: e716377b1218aa31833eea9283e306cad2a98aa1e0ac3f0c684761b5f221b703
Contents?: true
Size: 877 Bytes
Versions: 18
Compression:
Stored size: 877 Bytes
Contents
# Using the :resource_mapping configuration, you can register your own classes to be used # for the results from contentful. # # The key of the resource_mapping hash defines the resource type (object["sys"]["type"]) and the value is: # - the Class to use # - a Proc, that returns the Class to use # - a Symbol for a method of the ResourceBuilder object require 'contentful' class MyBetterArray < Contentful::Array # e.g. define more methods that you need def last items.last end end client = Contentful::Client.new( space: 'cfexampleapi', access_token: 'b4c0n73n7fu1', resource_mapping: { 'Array' => MyBetterArray, 'Asset' => ->(_json_object)do # might return different class if some criteria is matched Contentful::Asset end, } ) assets = client.assets p assets.class # => MyBetterArray p assets.last # => #<Contentful::Asset ...
Version data entries
18 entries across 18 versions & 1 rubygems