Class: Contentstack::AssetCollection
- Inherits:
-
Object
- Object
- Contentstack::AssetCollection
- Defined in:
- lib/contentstack/asset_collection.rb
Overview
Asset class to fetch details of files on Conentstack server.
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
Instance Method Summary collapse
-
#fetch ⇒ Object
Fetch assets uploaded to Contentstack.
-
#initialize(assets_array = nil) ⇒ AssetCollection
constructor
A new instance of AssetCollection.
Constructor Details
#initialize(assets_array = nil) ⇒ AssetCollection
Returns a new instance of AssetCollection.
8 9 10 11 12 13 14 15 |
# File 'lib/contentstack/asset_collection.rb', line 8 def initialize(assets_array=nil) if assets_array.nil? @assets = [] return self else @assets = assets_array.collect{|a| Asset.new(a)} end end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
6 7 8 |
# File 'lib/contentstack/asset_collection.rb', line 6 def assets @assets end |
Instance Method Details
#fetch ⇒ Object
Fetch assets uploaded to Contentstack
Example:
@assets = @stack.assets.fetch
21 22 23 24 |
# File 'lib/contentstack/asset_collection.rb', line 21 def fetch json = API.get_assets self.class.new(json["assets"]) end |