lib/contentful/resource.rb in contentful-0.2.0 vs lib/contentful/resource.rb in contentful-0.3.0

- old
+ new

@@ -17,14 +17,16 @@ float: ->(v) { v.to_f }, boolean: ->(v) { !!v }, date: ->(v) { DateTime.parse(v) } } - attr_reader :properties, :request, :client + attr_reader :properties, :request, :client, :default_locale - def initialize(object, request = nil, client = nil) + def initialize(object, request = nil, client = nil, nested_locale_fields = false, default_locale = Contentful::Client::DEFAULT_CONFIGURATION[:default_locale] ) self.class.update_coercions! + @nested_locale_fields = nested_locale_fields + @default_locale = default_locale @properties = extract_from_object object, :property, self.class.property_coercions.keys @request = request @client = client end @@ -37,10 +39,15 @@ # Returns true for resources that behave like an array def array? false end + # By default, fields come flattened in the current locale. This is different for syncs + def nested_locale_fields? + !! @nested_locale_fields + end + # Resources that don't include SystemProperties return nil for #sys def sys nil end @@ -94,9 +101,14 @@ end end # Register the resources properties on class level by using the #property method module ClassMethods + # By default, fields come flattened in the current locale. This is different for sync + def nested_locale_fields? + false + end + def property_coercions @property_coercions ||= {} end # Defines which properties of a resource your class expects