Class: Contentstack::AssetCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/contentstack/asset_collection.rb

Overview

Asset class to fetch details of files on Conentstack server.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#assetsObject (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

#fetchObject

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