Class: Contentful::Management::Field
- Inherits:
-
Object
- Object
- Contentful::Management::Field
- Includes:
- Resource
- Defined in:
- lib/contentful/management/field.rb
Overview
A ContentType’s field schema
Constant Summary
Constants included from Resource
Instance Attribute Summary
Attributes included from Resource
#client, #default_locale, #properties, #request
Instance Method Summary collapse
Methods included from Resource
#array?, #fields, #initialize, #inspect, #nested_locale_fields?, #sys
Instance Method Details
#deep_merge!(field) ⇒ Object
18 19 20 21 |
# File 'lib/contentful/management/field.rb', line 18 def deep_merge!(field) properties.merge!(field.properties.select { |name, _type| name != :items }) items.properties.merge!(field.items.properties) if (items.respond_to?(:properties) && field.items.respond_to?(:properties)) end |
#properties_to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/contentful/management/field.rb', line 23 def properties_to_hash properties.each_with_object({}) do |(key, value), results| if key == :items results[key] = value.properties_to_hash if type == 'Array' && value.is_a?(Field) else results[key] = value if !value.nil? && (value.respond_to?(:empty?) && !value.empty? || !value.respond_to?(:empty?) && value) end end end |