Module: Contentful::Resource::AssetFields
- Included in:
- Asset
- Defined in:
- lib/contentful/resource/asset_fields.rb
Overview
Special fields for Asset. Don’t include together wit Contentful::Resource::Fields
It depends on system properties being available
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- FIELDS_COERCIONS =
{ title: :string, description: :string, file: File }
Class Method Summary collapse
Instance Method Summary collapse
-
#fields(wanted_locale = default_locale) ⇒ Object
Returns all fields of the asset.
- #initialize(object) ⇒ Object
- #inspect(info = nil) ⇒ Object
Class Method Details
.included(base) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/contentful/resource/asset_fields.rb', line 40 def self.included(base) base.extend(ClassMethods) base.fields_coercions.keys.each do |name| base.send :define_method, Contentful::Support.snakify(name) do fields[name.to_sym] end end end |
Instance Method Details
#fields(wanted_locale = default_locale) ⇒ Object
Returns all fields of the asset
16 17 18 |
# File 'lib/contentful/resource/asset_fields.rb', line 16 def fields(wanted_locale = default_locale) @fields[locale || wanted_locale] end |
#initialize(object) ⇒ Object
20 21 22 23 24 |
# File 'lib/contentful/resource/asset_fields.rb', line 20 def initialize(object, *) super initialize_fields_for_localized_resource(object) end |
#inspect(info = nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/contentful/resource/asset_fields.rb', line 26 def inspect(info = nil) if fields.empty? super(info) else super("#{info} @fields=#{fields.inspect}") end end |