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.



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

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

#fetchObject

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