Class: Contentful::BaseResource
- Inherits:
-
Object
- Object
- Contentful::BaseResource
- Defined in:
- lib/contentful/base_resource.rb
Overview
Base definition of a Contentful Resource containing Sys properties
Direct Known Subclasses
Array, ContentType, DeletedAsset, DeletedEntry, FieldsResource, Link, Space, SyncPage
Instance Attribute Summary collapse
-
#default_locale ⇒ Object
readonly
Returns the value of attribute default_locale.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#sys ⇒ Object
readonly
Returns the value of attribute sys.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Definition of equality.
-
#initialize(item, configuration = {}, _localized = false, _includes = [], depth = 0) ⇒ BaseResource
constructor
A new instance of BaseResource.
-
#reload(client = nil) ⇒ Object
Issues the request that was made to fetch this response again.
Constructor Details
#initialize(item, configuration = {}, _localized = false, _includes = [], depth = 0) ⇒ BaseResource
Returns a new instance of BaseResource.
8 9 10 11 12 13 14 15 16 |
# File 'lib/contentful/base_resource.rb', line 8 def initialize(item, configuration = {}, _localized = false, _includes = [], depth = 0) @raw = item @default_locale = configuration[:default_locale] @depth = depth @sys = hydrate_sys @configuration = configuration define_sys_methods! end |
Instance Attribute Details
#default_locale ⇒ Object (readonly)
Returns the value of attribute default_locale.
6 7 8 |
# File 'lib/contentful/base_resource.rb', line 6 def default_locale @default_locale end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
6 7 8 |
# File 'lib/contentful/base_resource.rb', line 6 def raw @raw end |
#sys ⇒ Object (readonly)
Returns the value of attribute sys.
6 7 8 |
# File 'lib/contentful/base_resource.rb', line 6 def sys @sys end |
Instance Method Details
#==(other) ⇒ Object
Definition of equality
24 25 26 |
# File 'lib/contentful/base_resource.rb', line 24 def ==(other) self.class == other.class && sys[:id] == other.sys[:id] end |
#reload(client = nil) ⇒ Object
Issues the request that was made to fetch this response again. Only works for Entry, Asset, ContentType and Space
48 49 50 51 52 |
# File 'lib/contentful/base_resource.rb', line 48 def reload(client = nil) return client.send(Support.snakify(self.class.name.split('::').last), id) unless client.nil? false end |