examples/resource_mapping.rb in contentful-0.3.4 vs examples/resource_mapping.rb in contentful-0.3.5
- old
+ new
@@ -4,11 +4,10 @@
# 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
@@ -16,16 +15,16 @@
end
end
client = Contentful::Client.new(
space: 'cfexampleapi',
- access_token: "b4c0n73n7fu1",
+ access_token: 'b4c0n73n7fu1',
resource_mapping: {
'Array' => MyBetterArray,
- 'Asset' => ->(json_object){
+ 'Asset' => ->(_json_object)do
# might return different class if some criteria is matched
Contentful::Asset
- },
+ end,
}
)
assets = client.assets
p assets.class # => MyBetterArray