Module: Contentful::Resource
- Included in:
- Array, Asset, ContentType, DeletedAsset, DeletedEntry, Entry, Field, File, Link, Locale, Location, Space, SyncPage
- Defined in:
- lib/contentful/resource.rb,
lib/contentful/resource/fields.rb,
lib/contentful/resource/array_like.rb,
lib/contentful/resource/asset_fields.rb,
lib/contentful/resource/custom_resource.rb,
lib/contentful/resource/system_properties.rb
Overview
Include this module to declare a class to be a contentful resource. This is done by the default in the existing resource classes
You can define your own classes that behave like contentful resources: See examples/custom_classes.rb to see how.
Take a look at examples/resource_mapping.rb on how to register them to be returned by the client by default
Defined Under Namespace
Modules: ArrayLike, AssetFields, CustomResource, Fields, SystemProperties
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
rubocop:enable Style/DoubleNegation.
-
#default_locale ⇒ Object
readonly
rubocop:enable Style/DoubleNegation.
-
#properties ⇒ Object
readonly
rubocop:enable Style/DoubleNegation.
-
#raw ⇒ Object
readonly
rubocop:enable Style/DoubleNegation.
-
#request ⇒ Object
readonly
rubocop:enable Style/DoubleNegation.
Instance Method Summary collapse
-
#array? ⇒ Boolean
Returns true for resources that behave like an array.
-
#fields ⇒ Object
Resources that don't include Fields or AssetFields return nil for #fields.
-
#reload ⇒ Object
Issues the request that was made to fetch this response again.
-
#sys ⇒ Object
Resources that don't include SystemProperties return nil for #sys.
Instance Attribute Details
#client ⇒ Object (readonly)
rubocop:enable Style/DoubleNegation
29 30 31 |
# File 'lib/contentful/resource.rb', line 29 def client @client end |
#default_locale ⇒ Object (readonly)
rubocop:enable Style/DoubleNegation
29 30 31 |
# File 'lib/contentful/resource.rb', line 29 def default_locale @default_locale end |
#properties ⇒ Object (readonly)
rubocop:enable Style/DoubleNegation
29 30 31 |
# File 'lib/contentful/resource.rb', line 29 def properties @properties end |
#raw ⇒ Object (readonly)
rubocop:enable Style/DoubleNegation
29 30 31 |
# File 'lib/contentful/resource.rb', line 29 def raw @raw end |
#request ⇒ Object (readonly)
rubocop:enable Style/DoubleNegation
29 30 31 |
# File 'lib/contentful/resource.rb', line 29 def request @request end |
Instance Method Details
#array? ⇒ Boolean
Returns true for resources that behave like an array
60 61 62 |
# File 'lib/contentful/resource.rb', line 60 def array? false end |
#fields ⇒ Object
Resources that don't include Fields or AssetFields return nil for #fields
70 71 72 |
# File 'lib/contentful/resource.rb', line 70 def fields nil end |
#reload ⇒ Object
Issues the request that was made to fetch this response again. Only works for top-level resources
76 77 78 79 80 81 82 |
# File 'lib/contentful/resource.rb', line 76 def reload if request request.get else false end end |
#sys ⇒ Object
Resources that don't include SystemProperties return nil for #sys
65 66 67 |
# File 'lib/contentful/resource.rb', line 65 def sys nil end |