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.
10 11 12 13 14 15 16 17 |
# File 'lib/contentstack/asset_collection.rb', line 10 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.
8 9 10 |
# File 'lib/contentstack/asset_collection.rb', line 8 def assets @assets end |
Instance Method Details
#fetch ⇒ Object
Fetch assets uploaded to Contentstack
Example:
@assets = @stack.assets.fetch
23 24 25 26 |
# File 'lib/contentstack/asset_collection.rb', line 23 def fetch json = API.get_assets self.class.new(json["assets"]) end |